Push-to-open Door making

Hi,

I’m trying to make a door that when player is pushing against it (Walking/Running) through the door it moves. I need to know how to make such a thing.

I’ve tried “Hinge Joint” thing all but I cant seems to get it right. I mean the door doesnt move at all when pushing at it.

Please help.

1 Like

C’mon guys. Help the little noob. :smile:

Here’s one way – give your player a Rigidbody and a collider (e.g., Capsule Collider), not a Character Controller, so it’s part of the Physics simulation.

Put a rigidbody and collider on the wall or door frame, wherever the door connects. Put a hinge joint between it and your door. Add a Rigidbody and collider (e.g., Box Collider) to the door. Make sure Is Kinematic is UNticked. You may need to tweak Mass and tick Use Gravity.


Another way to do a door is to use a door open/close animation. (To close a door, play the open animation with speed == -1.) You can create animations straight in Unity using the Animation view. Add a trigger collider in front of the door. When the player enters the trigger, play the animation, and optionally a door-opening audio clip if you want. This way, you don’t need to set up a physics simulation of the door and its joint.

Hi, thanks for the reply. I think the Animation Open/Close system is bit disturbing. That’s why I’m going with the Physics thing.

And about it. Is it a must to add a Rigid body and a Collidor to the Door Frame and the Player controller? Because the player already got a Collidor (and a Rigid body too, as I remember).

Anyway I’ll try it and let ya know. Thanks.

Check out this tutorial, I used it to learn:
http://www.3dbuzz.com/training/view/unity-fundamentals/physics/10-hinge-joint

2 Likes

The door and player need rigidbodies and colliders. You probably don’t need to add a rigidbody to the frame/wall.

Cute. Also, just search Youtube. There’s a good tutorial that I can’t find, but you’ll probably have better luck.

@TonyLi : When I add a Rigidbody the player starts floating and Uncontrollable when pressed forward key. What now?

It depends on how you’re controlling the player, but I bet if you set the player’s rigidbody to Is Kinematic, it should be okay. On the door, however, leave Is Kinematic unticked.

I tried player with Kinetic on and off. With on, like I said before and when off player doesn’t move at all.

About the door. Is there anything I need to change in the settings of Hinge Joint. And how should the Anchor be?

Check out the 3DBuzz video that @gamedevelopingboy linked above. It should explain how to set up the Hinge Joint on the door.

What script(s) are you using to control the player?

Tbh. My connection is not good for watching videos. That’s why I posted here.

Please tell me everything step by step including setting the Hinge joint settings.

Please.

I encourage you to read the manual page on Hinge Joint. You’ll learn a lot more than just following step-by-step directions without understanding what they’re doing. The second paragraph of the Details section talks specifically about using Hinge Joint to set up a door.

Also, get your character working first.

Ok, figured how the Hinge Joint work. So, umm… what’s this Connected Anchor thing? And how to make the door rotate on the Axis when the player is pushing it?

The anchor specifies the axis where the door swings when the player pushes it.

I mean the Connected Anchor. And how to set a rotating limit, I don’t want the door rotating all around. And when it reaches the limit it come back to the original position.

I believe the Connected Anchor specifies where it connects to its parent. . I’ve always left Auto Configure Connected ticked, and it wasn’t in previous versions of Unity that I used.

To set the rotating limit, tick Use Limits and set them under Limits.

Tick Spring and fiddle with the values to make the door spring back to its original position. Or use a Spring Joint.

The Hinge tutorial will clear up a lot of this if you can get videos working.

Can you suggest me the values I should enter in the Limits. I used 90 as the Max limit and 0 as Min and it didn’t move at all.

First make sure the door moves at all. Untick Use Limits. You may need to adjust the mass of the door to make it light enough to move. Once this works, tick Use Limits again. Try a big range, like -180 to 180, to make sure it works, then gradually tweak it down.

Ok! Thanks!!!