Cant stop Rigidbody2D from moving

Hi guys,

Happy Friday!!!

I have a bunch of boulders chasing my player (Yes Indiana Jones rip off!)
when the boulders hit him, they kill him and his death animation plays, but the boulder pushes him along the ground.

usually i can stop a rigidbody by just using

rb.velocity = Vector3.velocity.zero;
rb.angularVelocity = 0;

but its just not working.

I also tried to disable the rigidbody all together by using

rb2d.isKinematic = false;

but nothing seems to work.

here is the die co routine that gets called when the collision occurs

IEnumerator DeadTimer()
    {
        rb2d.isKinematic = false;
        int waiting = 2;
        yield return new WaitForSeconds(waiting);
        playerCollider.enabled = false;
        sr.enabled = false;
        SceneManager.LoadScene("Stage1");
    }

Think i have it, the rb is in fact stopping but the boulder is just pushing him along, so i will try disable the collider

1 Like

Epoch!

Always good to see your adventures in Unity!

As you found out, setting a Rigidbody velocity to zero still lets things push it along.

Setting it to kinematic true should stop its computation. Kinematic true means “don’t simulate me,” which feels kinda backward. You’re setting it to false above, and it likely already IS false to be simulated.

You can also just destroy the Rigidbody, but his collider will continue to deflect rocks.

You could anchor the Rigidbody with a FixedJoint to the ground right there, then subsequent rocks hitting him should still cause him to jostle around a bit like a sack of meat… kinda grisly, but that’s gaming for you.

1 Like

“You could anchor the Rigidbody with a FixedJoint to the ground right there, then subsequent rocks hitting him should still cause him to jostle around a bit like a sack of meat… kinda grisly, but that’s gaming for you.”

Yes Yes Yes!

giving that a go…

1 Like