Problem with vector and charactercontrol

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)


CharacterControl control;
Vector3f goal;
Vector3f lookingFor;

    public void advance(float advanceAmount){
        lookingFor=new Vector3f();
        //Quaternion q=new Quaternion();
        //q=q.fromAngleAxis( rotationY, Vector3f.UNIT_Y );

I’ve commented out the Quaternion stuff (which was supposed to rotate the vector around the Y axis).

This should work (you can even use. GetviewDirection.mult(advanceamount))

The thing is, as you said there are physics involved so it might change a little.
I’ve noticed that when I use setWalkDirection that i get a bit off, so I correct that if I’m too far from my path

If you however want to scan if something is infront of you, rathee use some cone (like a viewfield)