HUD Compass

Thank you! Do you have any idea how set rotation a bit slowly? Now compass rotate awesome fast (it look like there is few compasses). I use chase camera

@Skatty said: Thank you! Do you have any idea how set rotation a bit slowly? Now compass rotate awesome fast (it look like there is few compasses). I use chase camera

To adjust the compass speed in the example above, just use a float for speed and multiply tpf by the speed during the update loop.

Can you post a screen shot of the multiple compasses? If this is also referring to the above example, I added two… one that is centered and rotates properly and another to show the difference when not centered… just to show where in the process of setting up the node yo would call Geometry.center().

I show u code from my cam and compass to rotation.
Camera:
[java] private float oldRotation, newRotation = 0;
[…]
chaseCam = new ChaseCamera(cam, playerModel, inputManager);
[…]
newRotation = chaseCam.getHorizontalRotation();
if (newRotation > oldRotation) {
compass.rotatePLUS(newRotation);
} else if (newRotation == oldRotation){

    } else {
        compass.rotateMINUS(newRotation);
    }
    oldRotation = newRotation;[/java]

And compass:
[java]/**
* @param rotation the rotation to set
*/
public void rotatePLUS(float rotation) {
this.rotation = rotation;
compassNode.rotate(0, 0, currentRotation+rotation);
currentRotation = currentRotation+rotation;
}

public void rotateMINUS(float rotation) {
    this.rotation = rotation;
    compassNode.rotate(0, 0, currentRotation-rotation);
    currentRotation = currentRotation-rotation;
}[/java]

rotate() is relative to the current rotation already.

1 Like
@pspeed said: rotate() is relative to the current rotation already.

Just as a reference… this is the same as the difference between setLocalTranslation and move. move is relative to the current position.

So how should I fix that?

@Skatty said: So how should I fix that?

Don’t include currentRotation.