So I have been trying to make a door that sits on a hinge that I can kind of walk into to open. I want it to move freely so I looked into the physics constraints tool. I set the constraints to hinge and used the presets that where set in the details panel for the hinge setting. However when I press play to test it, the door is set five feet behind the hinge and sticking into the ground. I can only assume that I need to get the doors location in a blueprint somewhere, but I want to be sure before I start that. Can anybody tell me if I did something wrong?
Note: the door is set to simulate physics
I would suggest creating the entire door inside of a blueprint. I used the SM_Doorframe and the SM_Door from the starter content.
Create an actor class blueprint.
In the Components tab, add the Doorframe as the root and the Door as a StaticMesh component under that. If you use the same assets I mentioned above you will need to move the door into place.
Add a PhysicsConstraint and place it midway up the door and where the hinge should be located.
In the PhysicsConstraint Details panel, add the door frame as Component 1 and the door as Component 2.
Adjust your setting to how I have pictured below. This will limit the movement.
The rotation is relative to the blueprint so you can place this any direction and duplicate it as many times as needed and it will always swing correctly.
If you have any questions, please feel free to ask.
thanks tj I was trying to make the door rotate on a pair of hinges instead of the frame, the frame idea works better. Thanks again
actually I am having trouble finding where to find where to add the components at.
Sure, once you create your blueprint, click the ‘Components’ tab (highlighted below in orange).
On the left, in the ‘Components’ panel, click the ‘Add Component’ dropdown and add 2 ‘Static Mesh’ components.
I set the Frame as the root component since it will be stationary (you can still move the blueprint around the level, it just won’t be swinging dynamically).
Set the Door as the 2nd component with ‘Simulate Physics’ enabled.
Use the ‘Add Component’ dropdown again and add a ‘Physics Constraint’.
Then set the ‘Physics Constraint’ setting to what I have pictured in my first post.
If I’m misunderstanding exactly what your asking, please post back and we can go into further detail.
Used this method to make doors and it works perfectly, really good job. Question though, how can I make the door return to it’s natural state (closed/no rotation)? The way it works now is that when I run through it, it opens just fine and it then swings shut. However it doesn’t stop swinging and will also swing open the other way again. I can’t add a doorjamb because that would lock me inside my buildings. Any ideas?
To adjust the physics swing as if the door is hitting a door jamb, you can adjust the Angular Rotation Offset. In this example I have a door that can swing 45° but I needed to offset the physics constraint so it would swing correctly, so I adjusted the Angular Rotation Offset by 45°.
As for the door stopping once it is ‘closed’, you could do something like the door is not simulating physics when it’s closed. For example: The player clicks the door and it simulates physics and opens the door a little (slight impulse) > If the door ever reaches the closed state (just a predetermined rotation value), the physics simulation on the door will be disabled again.
You could of course just forgo physics completely and just animated the door with blueprints to move between an open and closed state when the player interacts with it.
I hope that helps a bit. Let me know if you have any questions.
Well I was just looking for a way to make it somewhat automated without a specific trigger point, ie the door opens or closes based on the body for the player character, but also closes if the player character is not interacting with it. I would dearly like to avoid any clicking at all because I kind of hate that when it comes to environmental interaction. I suppose a small doorjamb would work in a sense, because the “push” of the player character would defeat the physics of the doorjamb once significant force is applied, but it would still be somewhat choppy and prone to bugs.
The other option would be to use an Angular Motor so the door always tries to push itself closed when something is not interacting with it. Just a heads up, Linear and Angular Motors sometimes take some trial and error to get them working the way you want.
That sounds promising Thank you so much for your input!
Ok sligth update, since your comment I set angular position strength and angular velocity strength to 20 - PERFECT results in my particular instance. A door on a doorframe with no hinge, only a physics constraint working as the hinge. The results are amazing, exactly what I was looking for!!
Nice, I’m glad it worked out!
Good luck with the rest of your project.