So I have code for a tower to turn towards an octopus when the octopus is in the world, however, when the octopus isn't in the world at all the game crashes. How would I modify this code to make it so that when the octopus isn't in the world it won't crash? I'm sure it's something relatively simple but I can't figure it out. Thanks!
public void turnTowardsOctopus()
{
Octopus o = (Octopus)getObjectsInRange(700, Octopus.class).get(0);
oX = o.getX();
oY = o.getY();
turnTowards(oX, oY);
fire();
}

