I’m not sure if this topic is better suited for the virtual-reality category, but I put it here just in case. Anyways I’m trying to rotate the observer around the headset’s location, but if I just rotate the observer it’ll rotate from the origin; since it isn’t translated with the headset. I’ve made an observerNode (parented to observer) which is translated to the negative of the headset’s position and I’ve made a playerNode (parented to observerNode) which is translated to the headset’s position. This seemed to work how I expected it to, the offset translates the playerNode to the location of the headset without moving everything forward infinitely. However, when I try to rotate the playerNode, it will stutter slightly then shoot both the headset and the node in a direction instantly.
playerNode = new Node();
observerNode = new Node();
observerNode.attachChild(observer);
playerNode.attachChild(observerNode);
rootNode.attachChild(playerNode);
…
oldPos = vrAppState.getFinalObserverPosition();
observerNode.setLocalTranslation(vrAppState.getFinalObserverPosition().negate());
playerNode.setLocalTranslation(oldPos);
…
if (vrAppState.getVRinput().getAxis(1, VRInputType.OculusThumbstickAxis).x != 0)
{
playerNode.rotate(0, vrAppState.getVRinput().getAxis(1,VRInputType.OculusThumbstickAxis).x * -tpf, 0);
}
Here’s an example of how the headset and node gets shot somewhere.
headset (-4.5064522E36, 0.88001215, -1.6770646E38)
observer (-4.5064522E36, 0.86536145, -1.6770646E38)
headset (-1.7193532E38, 0.86536145, -1.7835308E38)
observer (-1.7193532E38, 0.8543761, -1.7835308E38)
headset (-Infinity, 0.8543761, -2.321478E37)
observer (-Infinity, 0.841684, -2.321478E37)
headset (NaN, NaN, NaN)
observer (NaN, NaN, NaN)