Download

Simulating door physics: bounce after hitting max rotation?

Hey, I’m making a drag-able door, (it will be used for VR later, but not right now). for now, for simplicity and ease of testing sake, I just attached a sphere to my character as an interactor, that will be switched to the motion controllers later.

so I stripped the blueprints from Mitch’s VR lab sample, packed most of it into the door blueprint and managed to get it working, now I want to add some bouncing functionality, but I can’t figure it out. Currently the door stops when it’s in closed position, but it also stops after it hits the maximum open angle, what isn’t very natural. I wanted to make it bounce back after hitting the max angle, as if it hit a wall or something. here’s the code on my door blueprint:

(right click > open image in new tab for full size)

event tick calls for the IsDragging flag which is set on by pushing the grab button and off by releasing it. then while dragging, it sets the door’s rotation relative to my interactor, and after releasing the drag button, it checks for some stuff to see if the door should stop or keep going, and if it should keep going, it sets the rotation movement according to some physics simulation math.

so one of the things that flags the door movement should stop is if it is equal or higher the maximum door yaw. I detached this boolean but I didn’t work, it broke the door and as soon as it hit max yaw, it would return to closed position or something.
then I tried setting the initial yaw speed to negative of what it was the moment it reached max yaw, but didn’t work also. then I tried setting initial yaw angle to reverse the current angle after hitting max yaw, no game.

I also tried using a physics constraint, but it completely broke the code, and I couldn’t even figure out where to start debugging it so scrapped that idea too.

any suggestions?

Just for animation’s sake you could try using EaseOutBounce in iTween

Not sure how this would help, could you elaborate?

asked it on answerhub also

https://answers.unrealengine.com/questions/897778/simulating-door-physics-bounce-after-hitting-max-r.html

ok so I just took a complete look at all the things itween can do, and while it’s a fantastic tool (and I intend to use it for other purposes, thanks man), it doesn’t do what I want.

I have a formula for simulating a door’s movement when you drag it and let it go, it works specially great in VR because depending on the direction and speed you are dragging it before letting it go, it will continue the movement and slowly come to a stop based on friction and whatever is included on that formula.

the problem is that while having it instantly stop the movement when slamming the door closed is a good thing, it also stops it completely from moving when you open it abruptly and it reaches a set maximum open angle.

I just want to make it reverse the movement when it reaches the maximum angle, and continue doing it’s physical simulation, instead of completely stopping. but I don’t have a clue what on that formula could change it, I tried a few things and nothing did the trick, so that’s why I need some help

thanks

anyone? can’t figure this out