- Home /
How can I simulate a realistic collision between a metal axe and a door and prevent them from passing through each other?
I am trying to simulate an axe hitting a door in Unity and my plan was to have an audio clip play when the door and the axe collide. Unfortunately, I've been having trouble getting the collisions to work properly. I put a box collider on the door and a mesh collider on the axe but it just kept passing through. I was able to fix the clipping problem by putting a new camera on the axe, after which I tried to make the axe a rigid body but that just caused it to disappear. My player can't pass through the door so I assume the box collider is working okay and the problem might be with the axe.
I'd really appreciate it if anyone could advise me on what collider/rigidbody combinations I should be using in order to make the objects actually behave like 2 solid objects hitting each other or point out any errors in my approach.
Thanks in advance
Answer by hexagonius · Nov 14, 2018 at 07:13 PM
First of all, EVERYTHING THAT MOVES needs a Rigidbody. Things that do not currently interact physically (closed door) have their isKinematic boolean set to true. Everything that never moves does not need a Rigidbody. And finally, things that are moved need to be moved in the FixedUpdate, be it the velocity is set or AddForce is called. No Translate, transform.position =... all teleportation calls break it. P.S.: MovePosition and MoveRotation are for kinematics you want to read velocity data from, even though they're not physically moving, but that's not important here.
Bottom line, door, kinematic, axe physically moved in FixedUpdate.