Skip to main content

My ball is jumping on a 3d circle sometimecylinder, and sometimes the ball gets stuck inside the circlecylinder.ball The ball has a rigid body and its continuousit's continuously dynamic and. The circle also havehas a mesh collider. hereHere is my jumpthe code..

void Update () { to make the ball jump:

void Update () {

    if(Mathf.Sign(rg.velocity.y)==-1){

        isforceApplied=true;
    }



}

void OnCollisionEnter(Collision collisionInfo)
{


    if(isforceApplied==true){

        isforceApplied=false;
        rg.AddForce(transform.up*forceAmount,ForceMode.Impulse);

    }


}

enter image description here

enter image description here

ball is jumping on 3d circle sometime stuck inside the circle.ball has rigid body and its continuous dynamic and circle also have mesh collider. here is my jump code..

void Update () {

    if(Mathf.Sign(rg.velocity.y)==-1){

        isforceApplied=true;
    }



}

void OnCollisionEnter(Collision collisionInfo)
{


    if(isforceApplied==true){

        isforceApplied=false;
        rg.AddForce(transform.up*forceAmount,ForceMode.Impulse);

    }


}

enter image description here

enter image description here

My ball is jumping on a 3d cylinder, and sometimes the ball gets stuck inside the cylinder. The ball has a rigid body and it's continuously dynamic. The circle also has a mesh collider. Here is the code to make the ball jump:

void Update () {

    if(Mathf.Sign(rg.velocity.y)==-1){

        isforceApplied=true;
    }



}

void OnCollisionEnter(Collision collisionInfo)
{


    if(isforceApplied==true){

        isforceApplied=false;
        rg.AddForce(transform.up*forceAmount,ForceMode.Impulse);

    }


}

enter image description here

enter image description here

Source Link

Unity Ball moving inside the surface

ball is jumping on 3d circle sometime stuck inside the circle.ball has rigid body and its continuous dynamic and circle also have mesh collider. here is my jump code..

void Update () {

    if(Mathf.Sign(rg.velocity.y)==-1){

        isforceApplied=true;
    }



}

void OnCollisionEnter(Collision collisionInfo)
{


    if(isforceApplied==true){

        isforceApplied=false;
        rg.AddForce(transform.up*forceAmount,ForceMode.Impulse);

    }


}

enter image description here

enter image description here