so I got my VIVE a few weeks back and have been prototyping out some stuff… but one thing that is giving me a real big head ache is creating a door that a player can open with his motion controllers. I feel like im going mad trying to figure this out! lol
I have trying using physics constraints, attaching the controller to the door knob, etc…
my door doesn’t have to be physics based i just figured that would be easiest but i was wrong. anyone got any ideas on how to open and close doors? any help would be much appreciated
Now that I woke up with a different mind set i’m thinking maybe I could do this it using a timeline in the door Blueprint and getting the movement of the motion controller in the relative space of the “motioncontrollerpawn” (the player pawn). get the original location of the motion controller (Hand) when first interacting, then if the movement is positive rotate the door forward and if the location is is going negative pull the door back?
I’m trying to get something like this but with the motion controllers not a mouse Interactable Physical Door (Unreal Engine 4) - YouTube
please any ideas?
found some good tutorials
going to try a mix this video and adding a phyics Handle on the motion controller.https://youtube.com/watch?v=WUprlq8aibc
will post if works as needed
If you’re trying to do a swinging door, keep in mind that every door is on hinges. This should suggest to you the direction of your solution.
So, the hinges are a pivot point and you know exactly where they’re located, and you also know the size of the door. You also know where the door knob is, and where the players hands are located and whether they are holding down a button or not. This is about all the info you need
The approach I would take is to consider the pivot points (hinges) to be the center of a circle and what you’re going to want to do is sweep the door around on these pivot points. If you look at doors in real life, they only open one direction and have a maximum range between 0->90 degrees. They only open if your hand is on the handle and you push or pull on the door. This should suggest to you the way players should interact with doors: they grab the handle and pull or push the door. So, if a player is holding onto the handle of the door and moving their hand, you would be looking to match the angle of the door to the angle between the players hand and the pivot point. You’d probably want to do an offset to account for the distance between the handle and the door as well, and have threshold values for when the hand is actually holding the handle vs. too far away. Alternatively, the handle could just be used to latch the door in place, and a player could push the door open?
Anyways, I leave the rest of the math and implementation to you. It should be pretty straight forward from here.
first off thanks a ton for the reply!!!
what I am gathering from your reply is that maybe I dont need to rely on physics so much, (maybe after it has been open I’ll start the simulate physics) but for moving the door around I should use more math? The way you broke it down helped me digest the problem better… sometimes I get micro focused and lose sight of the big picture. I’m about to grab some dinner but I whipped up a simple test blueprint considering what you said and got a box to “look at” the character. i’m guessing that I could do the same with the motion controller and the door? (with the pivot point in the right spot, of course) am I on to the right idea? Here is my simple Blueprint set up that I’m thinking I can use. After I get back from dinner I will test this out and let you guys know the results … thanks again for reply!!!
so …the steps in my brain go something like this
-detect hand on knob
-get input (trigger)
-use math below to look at hand
-when let go of trigger stop interaction
Were you able to get some sort off door working in VR? I am having the same issue and was wondering if anyone has been successful.
Did you have any luck with this? I am trying to figure out how to create a door that I can open with the vive motion controller. I am new to unreal so kind of at a loss of where to start. You seemed like you had the best luck or at least determination to get it working.
Why don’t you guys try this one. It uses a (free) plugin but for getting your head around it’s maybe a good start (also has a door sample in it). I also suggest you take a look at the “Content Examples” & “Blueprints” stuff you find in the Learn tab of the Epic Launcher. Mathew Wadstein also has some great stuff and it’s easy to adapt for VR.
There’s a door in the VRExpansionPlugin template.
I would also add a heavy hitting vibration to the controller when the player is trying to open the door the wrong way or if it’s locked. That way they can feel that something is wrong.
Did you ever figure this out?
I’d try putting a volume around the door handle. If the controller is inside this volume and grips, save the rotation of the controller. Then, if it rotates around the appropriate axis enough degrees before leaving the volume, the user has turned the door handle. Then I’d be lazy and have a timeline animate the door open
I almost finished the door blueprint for both push and pull interactions in friday. It’s not so complicated. To get required Yaw angle just find an arctan of horizontal vector from door axis to controller. It works if your door is vertical.
Calculate current speed in every frame (Current Yaw - Previous Yaw) / DeltaTime and compare absolute speed with some min value to decide if you need convroller vibration / sound or not.
Pushing is slightly more complicated. At first, after BeginOverlap(…) you need to calculate controller velocity vector (Current Location - Previous Location) / DeltaTime]. Then you compare initial velocity with current velocity vector. If they’re codirectional (dot product > 0) and [current door rotation speed generated by controller] (image above) is greater then [current door rotation speed minus const deceleration], set current door speed to [current door rotation speed generated by controller]. Otherwise, simply apply deceleration to the current door rotation speed. Then apply this speed to door rotation itself. EndOverlap Event is not required here, door stops when current door rotation speed decreases to zero by deceleration.
Have you tried using physics constraints component ?
Not me. I tried at first, but it didn’t work properly.
YuriNK can you explain to me what should be in the Active controller, Door Root Axis and Start Pulling Offset nodes? I’m a novice and I can not figure it out.
Check out Mitch’s VRContentExamples, it has doors, drawers, levers and such. It’s pretty much my go to for VR Starter Content at the moment. I also find the pawn to be a lot more adaptable than the default VR pawn.