Move an object along the x-axis of view in VR Camera.

In a VR application, I have an object e.g. BOX. What I want is that when the player will see the scene in 360, that BOX should follow the current view in x-axis only.

In other words, in VR app having a Main Camera(Right + Left), when scene is viewed in 360 then what co-ordinates are changing. Actually during the view around 360 the camera transform does not change.

If I make this BOX as child of Main camera, it will follow the camera view completely. But I want it to follow on x-axis only. On y and z it should remain fixed.

If you want to move it to the right (x-axis) relative to the camera, simply use camera_transform.right. If you want it to stay at a certain line (the x-axis for example) but stay as close as possible to the camera, you should use something called a (perpendicular) projection. It’s a relatively easy piece of vector math that always comes in handy with game development, I find. Look it up :slight_smile:
(You are specifically looking for the length of the projection vector)

This may be a bit too much and there might be an easier solution to your problem (or I might have misinterpreted your problem in the first place)

Good luck!

-Gameplay4all