RigidBody2D rotation at a fixed point

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Firty

I can move and rotate a RigidBody2D very easily when I hit it using a Kinemact.
But how do I keep (fixed) at one point?
The idea is to make a top-down door, where it opens when I knock, and then it goes back to its original location. It’s possible? I tried several things, but I couldn’t find a way to make a hinge.

I’am Brazilian… By Google Translate…

:bust_in_silhouette: Reply From: njamster

You could use a PinJoint2D to connect the RigidBody2D of your door to a StaticBody2D where the hinge is supposed to be. However, be prepared for a lot of weird glitches! I’d not recommend using a RigidBody2D for something as simple as a door, especially as it seems you’re not interested in physics anyway. Just create a StaticBody2D, rotate it by 90° if it collides with the player and try to rotate it back after a timer runs out.

Thanks for the idea! After several tests I had the idea of ​​using two PinJoint2d, the first one was at the hinge location with a smoothness of 0, while the second one was used to force the door to go back to the place starting with smoothness at 16. It was better than I expected!

Firty | 2020-04-16 13:32