- Home /
Western door with Hinge Joint
Hey guys. I have a question.
I want to make a door, like Western Saloon doors, whem the player walk to the door he push him, and when he pass the door close like a spring.
The problem is that i cant push the door when I walk to it.
Someone can help me please ?
Edit: PS: I'm using hinge joint but I can't use it with FPS Controller, I need to make it to interact with Character Controller
Exemple, I cant shoot in door, and it move, but if I push with FPS Controller it dont work
PS: I'm using hinge joint but I can't use it with FPS Controller, I need to make it to interact with Character Controller
did you manage to solve this if you did how did you done it?
Answer by Ludiares.du · Nov 24, 2011 at 08:59 PM
I think it must be used with rigidbodies, not charactercontrollers, not sure, though
Answer by Ludiares.du · Nov 23, 2011 at 12:35 PM
Add the hinge joint, set the axis and the anchor, and select the body it is connected to. It should work.
I can only make the door open, shooting on it, but I'm using FPS Controller, and it don't work to it =/
Answer by GraviterX · Dec 04, 2013 at 02:01 AM
It need to be done with rigidbodies. Attach one to your door, and use this script: // this script pushes all rigidbodies that the character touches var pushPower = 2.0; function OnControllerColliderHit (hit : ControllerColliderHit) { var body : Rigidbody = hit.collider.attachedRigidbody; // no rigidbody if (body == null || body.isKinematic) { return; } // We dont want to push objects below us if (hit.moveDirection.y < -0.3) { return; } // Calculate push direction from move direction, // we only push objects to the sides never up and down var pushDir = Vector3 (hit.moveDirection.x, 0, hit.moveDirection.z); // If you know how fast your character is trying to move, // then you can also multiply the push velocity by that. // Apply the push body.velocity = pushDir * pushPower; }
Hope this helps!