Hello everyone, this question may sound stupid for you but i cant figure out how to change the speed at which an enemy ship rotates towards the player. Plz dont post anyhateful comments its only a month i got into jme . Here is my code:
protected void controlUpdate(float tpf) {
Vector3f playerDirection = player.getLocalTranslation().subtract(spatial.getLocalTranslation());
playerDirection.normalizeLocal();
playerDirection = playerDirection.add(velocity);
velocity= playerDirection.normalizeLocal().mult(speed);
if (spatial.getLocalTranslation().distanceSquared(player.getLocalTranslation()) > 2000){
float actualRotation = Main.getAngleFromVector(playerDirection);
if (actualRotation != rotation) {
spatial.rotate(0, 0, actualRotation-rotation);
rotation= actualRotation;
}
spatial.move(velocity);
}
Note:its a 2D game, the spatial seeks the player and rotate in its direction fine, i only want to control the speed at which it rotates.Thanks for your help.