Reputation: 415
I am making a Unity game for Oculus VR using C#.
I want to test a simple jumpscare where the object appears suddenly right into your "face".
I have problems with setting the position of this object. Right now I pass players position and rotation to this function.
public void ScareMe(Vector3 pos, Quaternion rot){
girlSmiling.transform.position = new Vector3(pos.x, 0.9f, pos.z- 1.3f);
//girlSmiling.transform.LookAt (pos);
girlSmiling.transform.rotation = rot;
//other irrelevant stuff
}
I need to maintain y position for my scare (girl) because in Oculus your height is adjustable and it doesn't correspond to your environment, so I need to leave it at 0.9f. I tried LookAt function but it doesn't work as good as I would like it to work.
The problem remains that girl appears right in front of me only when I look straight. When I move my head around, which is more likely to be a real in game situation for Oculus, she appears a bit to the right or left or even at the back.
I dont understand why it is happening. How can I set her position so she is always facing me right in front of me?
Upvotes: 0
Views: 1056
Reputation: 2936
You always can try to make your scare girl being children of your camera-head object. Doing this the object will follow the camera head and rotate with it.
girlSmiling.transform.parent = ...Here you can put the transform of the Camera head.
You can position the object before parenting or after parenting them (with local position should be easier).
I hope this helps, good luck!
Upvotes: 1