I have a CharacterControl, and I want to obtain a position that is “in front” of the CharacterControl itself and advanceAmount
away.
According to my tests, I get random results.
I am uncertain whether the code below is conceptually wrong, or if some randomness is to be expected because the current position of control is determined by physics (the terrain is not flat, therefore the control itself is always moving)
Code:
CharacterControl control;
Vector3f goal;
Vector3f lookingFor;
public void advance(float advanceAmount){
lookingFor=new Vector3f();
goal.x=control.getViewDirection().x;
goal.y=control.getViewDirection().y;
goal.z=control.getViewDirection().z;
//Quaternion q=new Quaternion();
//q=q.fromAngleAxis( rotationY, Vector3f.UNIT_Y );
//q.mult(goal,goal);
goal.mult(advanceAmount,goal);
lookingFor=control.getPhysicsLocation().add(goal);
}
I’ve commented out the Quaternion stuff (which was supposed to rotate the vector around the Y axis).
Thanks!