Forum Discussion
kenter
12 years agoHonored Guest
Camera Y rotation adds rotation force to player?
Hi all, I'm trying to implement something that seems fairly straightforward, but I can't seem to make it work...here it goes... Currently, "Tracker Rotates Y" makes it so that the camera Y rotation...
Felix12g
12 years agoHonored Guest
If you store the "forward" view orientation at the beginning with the GetTrackerOrientation() call that cyber mentioned, you can get an easy input right from the headset without needing to mess with the cameras. Checks after the center is stored would give you an angle difference, you'll just want to pull out the Y axis and multiply.
I'm guessing this approach should work, its pretty close to what you've posted, but I think working with the tracker rather than the camera angles is probably going to be easier. The other aspect here is that you can decouple the camera from the heirarchy of the whole system if you wanted and it would still work fine.
Other note, if you're going to be running this every frame, store a reference to the Transform you're going to be rotating, calling the components like that is more expensive.
I'm guessing this approach should work, its pretty close to what you've posted, but I think working with the tracker rather than the camera angles is probably going to be easier. The other aspect here is that you can decouple the camera from the heirarchy of the whole system if you wanted and it would still work fine.
Other note, if you're going to be running this every frame, store a reference to the Transform you're going to be rotating, calling the components like that is more expensive.
public class TrackerTurn : Monobehavior {
Transform rootObjToSpin;
forwardRotationVariable = blah; //I think it returns a quaternion?
float turnSensitivityMultiplier = 1f; //Use this to multiply the rotation amount
float turnInputVariable = 0f; //Store your input, then use it however you want
void Awake()
{
forwardRotationVariable = GetTrackerOrientation();
}
void Update()
{
currentRotationVariableLocal = GetTrackerOrientation();
float yDifference = GetGoodAngleValue(forwardRotationVariable, currentRotationVariableLocal);
turnInputVariable = yDifference * turnSensitivityMultiplier; //Clamp it to -1/1 if you want
}
float GetGoodAngleValue(float forward, float current)
{
return compare the two, grab the y and spit that angle as a positive or negative amount back out;
}
}
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 11 months ago
- 4 years ago
- 9 years agoAnonymous