This is what I am trying to achieve. The player will move in the x,y,z direction using a joystick, I have this working already. Now I am trying to add head tracking, i.e the camera moves using a tracker on the players head. I have the position values coming in from the tracker fine. I want both the joystick and the head tracking to be working together.
However, what I am struggling with is combining the joystick input and the tracker input. Here is my script so far.
You set the camera rotation by by accessing "fpc.transform.rotation". The real question is what is the nature of the input from the head tracker, and what kind of behavior do you want the camera to have?
Very good video, I imagining taking the heads rotation relative to a deadzone and using that to rotate the camera, i.e. player looks to the side of the screen and the camera turns to face that way. The effect in the video would be much more challenging to implement.
From your description and your code it’s not really clear what you actually want to do. In your last line you set the position to an absolute value. You do this every frame so you can’t add a relative motion to it since you reset it each frame.
I guess that you want the headtracking position as offset to your actual character position.
Since headtracking usually just affects the camera and not the player you could simply apply the tracking position to the localPosition of the camera only. So the camera still moves along with the player but gets an offset from the headtracking. Depending in which space you get your tracking information (probably in camera local space) you might have to transform the position into “local player space”. However that soley dependy on what kind of game you actually have (fps, tps, 2.5d sidescroller, …)
and I apologise for the formatting, I can't get it correct.
– harveyhbYou set the camera rotation by by accessing "
– KellyThomasfpc.transform.rotation". The real question is what is the nature of the input from the head tracker, and what kind of behavior do you want the camera to have?@harveyhb: ![HowToFormatCode][1] [1]: https://dl.dropboxusercontent.com/u/7761356/UnityAnswers/Images/HowToFormatCode.PNG
– Bunny83Very good video, I imagining taking the heads rotation relative to a deadzone and using that to rotate the camera, i.e. player looks to the side of the screen and the camera turns to face that way. The effect in the video would be much more challenging to implement.
– KellyThomas