How to stop door from rotating too much?

I want to make it where you can not push a door farther than a certain limit, can anybody help?
https://playcanvas.com/editor/scene/1590781

Hi @Brent_Reddick!

You use a dynamic rigidbody for your door. The easiest solution is to block the rotation with another (invisible) rigidbody. This can be a part of the wall for example.

I see you work in a very dark scene. For my own project with a dark scene, I use an extra ‘editor’ light, that I turn off by script at start of the game. This makes it easier to work in the editor.

This is not possible with your current setup. I changed the setup in a fork of your project, but even then it doesn’t work as expected. I will try to create an sample project, so maybe someone else can tell what’s wrong.

Below a sample project of my setup.

I hope someone can explain why this doesn’t work as expected and know how to solve the problem.

https://playcanvas.com/project/1011862/overview/doorway

ok

why is it not possible?

Because your setup is different to get the rotation point on the correct position. I created a workaround for this, by using an entity with compound collider and rigidbody on the position of the rotation point. Unfortunately, the door is not stopped by another rigidbody and I don’t know why.

maybe its because it is inside the wall?

My setup is not inside the wall?

Ok, what if after you push the door it slowly rotates back into original position, kinda like this but newer

https://playcanvas.com/project/363871/overview/tutorial-hinge-joint

@Albertos

We have to wait.

I’m on mobile so I can’t check this project.

When I looked into this, it looked like if all linear factor is 0, it doesn’t do collision against a static or a kinematic rigidbody which is very odd and probably something to do with Ammo.

I would use the Ammo constraints for this which isn’t official API but Will has an old project that can help make this easier: https://playcanvas.com/project/618829/overview/physics-constraints

You will need to be prepared to experiment a lot with it though

1 Like

so jut just not make the linear factor 0?

I tried that, but then the door will move. Probably there are workarounds to solve this too, but it’s not ideal.

I think I got it to work I just added a entity that holds it in place :slight_smile:

How does an entity hold it in place?

I think my workaround would be to set the linear factor to 0.001 and teleport the entity back to it’s original position every collision. Something like that.

Is there a way to make it slowly rotate back into its original position every time you open it?