My world starts by spawning a spaceship. I try to run this code after the spaceship has been spawned, yet a nullpointerexception occurs. Could you help me fix this?
public void turnTowardsSpaceship() {
List<Spaceship> spaceships = getWorld().getObjects(Spaceship.class);
for (Spaceship spaceship : spaceships) {
ssX = spaceship.getX();
ssY = spaceship.getY();
turnTowards(ssX,ssY);
}
}