I am trying to place an object in front of my camera, facing the camera.
The object should be placed 1.1m in front of, and 0.4m under the camera’s position.
The object should not get tilted by the cameras rotation, and always have it’s up-vector in the Vector3.up direction.
This is what I have currently:
I placed the obj at camera.position. Then I rotated it at y-axis to face the same direction as the camera. After that I translated the object in this direction.
Yes kind off. But I am only interrested in rotation.y, the object I am rotating should not get tilted in any way, and only rotated around y-axis.
But whenever I set rotation.x and rotation.z to 0, the y-rotation flips at 180 degrees
Not in my case I think. I don’t want the object to move with the camera, but I want to place it in front of the camera at a certain time.
To give some context: I’m working on an AR app, and want to place the Object in front of the camera, when the user taps the screen. The object’s position should be 1.1m away, and 0.4m under the camera’s position. Also, the object should be facing to the camera, only be rotated around y-axis.
But at the moment, this only works, if the user doesn’t turn around with his phone more than 90 degrees. After +90 or -90 degrees, the y-rotation of the camera flips, resulting in the object not being placed in front of the camera anymore.