- Home /
Rigid body Help Please
Im fairly new to unity so what im about to ask maybe silly but anyways
im using unity 3.2 and im building a 2d platformer using unitys 2d platformer controller. i wanted to add some obstacles in the way of my character Eg a pile of boxes and when my character jumps or runs into them they get knocked over and roll about the place. i dont however want my characters position to be effected. ive tried adding a rigid body to the boxes but they wont fall when the player hits them. and when i added one to the player also the player went "crazy"
So my question really is can my character hit a box with a rigid body and have the box be affected by physics but my character be unchanged.
Any help would be awesome
Answer by Kay3D · Mar 15, 2011 at 11:40 AM
Maybe you could add a collider to the object and a rigidbody(so it behaves properally) and then add a script that on the OnColliderHit function you find your character controller and set the position of it relative to where it was just before it hit the object. I dont know if it helps that much! Sorry Im a newbie to Unity too! Great tutorials here might help 3DBuzz Its all the basics of Unity really helped me
I was having the same issue, and this answer pointed me in the right direction. To improve upon it, add OnControllerColliderHit to your CC.
https://docs.unity3d.com/ScriptReference/$$anonymous$$onoBehaviour.OnControllerColliderHit.html