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

Add the hinge joint, set the axis and the anchor, and select the body it is connected to. It should work.

I think it must be used with rigidbodies, not charactercontrollers, not sure, though

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!