Forum Discussion
j_coleman
5 years agoExplorer
3rd Person Camera Relative Movement - Strange Behavior After Build to Quest
I'm working on a simple game where a 3rd person player is controlled by the 2d axis movement on one of the controllers. The movement is camera relative. Depending on the direction the headset is faci...
- 4 years ago
I figured this one out. The problem was with the following statement:
if (targetDevice.TryGetFeatureValue(CommonUsages.primary2DAxis, out Vector2 primary2DAxisValue) && primary2DAxisValue != Vector2.zero)
Specifically, the problem was caused by - primary2DAxisValue != Vector2.zero. Apparently, the primary 2d axis value is rarely exactly zero. There is always a small amount of drift, which was causing the player to move when I let go of the control stick. I fixed this by replacing the problematic statement with:
if (targetDevice.TryGetFeatureValue(CommonUsages.primary2DAxis, out Vector2 primary2DAxisValue) && TestSensitivity(primary2DAxisValue))
Then adding a method like the below:
private bool TestSensitivity(Vector2 inputToTest)
{
if ((inputToTest.x > primary2DAxisSensitivity || inputToTest.x < -primary2DAxisSensitivity) && (inputToTest.y > primary2DAxisSensitivity || inputToTest.y < -primary2DAxisSensitivity))
{
return true;
} else
{
return false;
}
}You'll need to define a float, primary2DAxisSensitivity somewhere. I chose 0.01 and things worked well.
j_coleman
4 years agoExplorer
I figured this one out. The problem was with the following statement:
if (targetDevice.TryGetFeatureValue(CommonUsages.primary2DAxis, out Vector2 primary2DAxisValue) && primary2DAxisValue != Vector2.zero)
Specifically, the problem was caused by - primary2DAxisValue != Vector2.zero. Apparently, the primary 2d axis value is rarely exactly zero. There is always a small amount of drift, which was causing the player to move when I let go of the control stick. I fixed this by replacing the problematic statement with:
if (targetDevice.TryGetFeatureValue(CommonUsages.primary2DAxis, out Vector2 primary2DAxisValue) && TestSensitivity(primary2DAxisValue))
Then adding a method like the below:
private bool TestSensitivity(Vector2 inputToTest)
{
if ((inputToTest.x > primary2DAxisSensitivity || inputToTest.x < -primary2DAxisSensitivity) && (inputToTest.y > primary2DAxisSensitivity || inputToTest.y < -primary2DAxisSensitivity))
{
return true;
} else
{
return false;
}
}
You'll need to define a float, primary2DAxisSensitivity somewhere. I chose 0.01 and things worked well.
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
- 3 years ago
- 1 year ago