- Home /
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!
Answer by robertbu · May 05, 2013 at 03:00 AM
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.