Sliding an object on x axis in VR

Hey guys, I am trying to slide an object on an axis only From the pickup cube I am trying to use the difference between the “Arrow” and the “Cube” to translate the door on x axis. For some reason as soon as I grab the “Cube” the door is flying somewhere that I can’t see and the value of that position, when I use a print string is crazy high. Something is wrong for sure but don’t know what it is really I tried to clamp the value as well in between a minimum of -100 but the door start with an offset of -100 when I play the level. Appreciate a bit of help please? Thanks in advance guys


You can:

  1. For a sliding door: when triggered, you’ll need to match the controller’s world location to the door’s relative location, then you need to shoot a line from the translated position of the controller to the door to tell it to move parallel in X.

Basically:

  • Point A is ( 0, 0, 0 ) relative to your door.
  • Point B is the VR controller relative to the door.
  • You need to find line c.
  • Draw line a or draw line b to get point C (already a given if you found point B)
  • And finally set door’s X to point C
    image

You can limit the door’s movement by clamping the C point.

  1. Or…

You’ve found line b and set point C.

1 Like

Thanks for that pezzott1
Understand the logic now just need to put that in place.
What I have in place is the door, an Arrow and a cube.
The arrow and the cube got the same position in the Door_BP
The arrow though is parented to the door, so move with it.
My goal was to get the position of that arrow and the one from the cube (That is picked up by the controller) and just doing a difference float in between them in X axis and add that difference to the X axis of the door.
Surely it is wrong as it is not working :wink:
I will try to figure out what you explain and give it a go.
Thanks again for your help
Take care
Cheers,
Matthieu

Hope it helps! I’ll do a quick demo later and share for reference.

That will be awesome really pezzott1
If it is not to much to ask you
Thanks a lot in advance
Cheers,
Matthieu

Hit the wall a few times… :rofl:door2 - YouTube

I’ll comment it tomorow, but here it is if you want play with it. This is everything for the door. Just added that the hand needs to be in range of the handle to move the door and enable / disable tick only when in use.

1 Like

Thanks so much for your help on that
I will try to reproduce that based on my Door_BP
Really busy and haven’t got time to try today.
Can I ask you how you did setup your doorBP please?
Will be a big help as you have “Door”, “PickupActor”, "SceneRoot"and “Handle”
Thanks a lot again Pezzott1
Really appreciate the help and happy to see that you have a version working :wink:
Really Nice

1 Like

Door and pickupActor are same level under scene root. Handle is child of door.

  • Scene Root
    • Door
      • Handle
    • PickupActor
1 Like

Thanks so much For all those explanation
I should be able to make it working with your help
I will let you know
Take care Mate
Cheers,
Matthieu

1 Like