I have a ship, and it follows a dummy object directly in front of it. When it reaches a certain distance from the center of the world, I would like to make it turn directly towards the player's ship. For that, I would like to calculate the degree between a direction vector composed of the ship's transformed center and its dummy's transformed center and the player's ship's transformed center. How would I go about doing that?
I've written two simple methods, a turnTo which simply calculates the number of iterations (in x degree segments) that the ship will turn on its Y axis, and a turnAround which turns the number of iterations that turnTo calculated (as follows). So how do I implement turnTo()?
protected void turnAround() { //RUNS THE TURN-AROUND LOOP FOR THE ENEMY FIGHTER
if (!turning && i == numberOfTurnSegs) {
turning = true;
i = 0;
}
tieFighter.rotateAxis(enemyShip.getYAxis(), (float)Math.toRadians(10));
gameInstance.moveTowards(enemyShip, tieGuide.getTransformedCenter(), .1f); //THIS MOVES IT FORWARD
i++;
if (i == numberOfTurnSegs) {
gameInstance.moveTowardsMinusY(enemyShip, tieGuide.getTransformedCenter(), 1f); //GET IT AWAY FROM SKY SO NO MORE COLLISION
turning = false;
lastTurn = System.currentTimeMillis();
}
}