Hi
How can i rotate an object to face another object, it is to be placed as the outcome of an if statement.
So if object b is.... turn object b to face object a?
Thanks for your help!


static int x, y; public void act() { x = getX(); y = getY(); }
// put the coordinates of the object you want to turn to public int point_to(int x, int y) { int dx = x - getX(); int dy = y - getY(); double rotation = Math.atan2(dy, dx); rotation = Math.toDegrees(rotation); return (int)rotation; } public void act() { setRotation(point_to(ActorA.x, ActorA.y)); }
turnTowards(ActorA.getX(), ActorA.getY());
ActorB.turnTowards(ActorA.getX(), ActorA.getY());
static int x, y;
public void act(){ if (BinBump()) { turnTowards(lorry.getX(), lorry.getY()); } }