Make Ball Roll after Player Runs into it?

Hi,
I have a player that is a capsule and i want a ball to roll when the player hits. I have setup a rigidbody on the ball but nothing happened. I am assuming i have done it incorrect.
I have only been using unity one week so please help!

1 Answer

1

I’m guessing your character uses a CharacterController script rather than a Rigidbody. If so, take a look at OnControllerColliderHit() and the example script. The script moves the object based on the direction of the hit. In order to roll the object, you will need a bit more work. You can use Rigidbody.AddForceAtPosition() with a position up a bit from the center of the ball, or you could use Vector3.Cross() to calculate an axis of rotation and directly set the Rigidbody.angularVelocity.

ok thanks ill see how it goes then get back to you

–

everything works!

–