Hello,
I made an enemy that shoots two projectiles at intervals. Here is the code for that:
The problem is that if the main actor gets hit by the first projectile (which removes the main actor) it causes an error, because the second projectile tries to turn towards the nonexisting main actor.
Error message: "java.lang.IllegalStateException: Actor not in world. An attempt was made to use the actor's location while it is not in the world. Either it has not yet been inserted, or it has been removed."
is there a way to fix this without losing the "turntowards" ability?
Thanks :)
private void shootProjectiles() { firstShotTimer--; if (firstShotTimer <= 0) { getWorld().addObject(projectile1, getX(), getY()); firstShotDone = true; } if (firstShotDone) { secondShotTimer--; } if (secondShotTimer <= 0) { getWorld().addObject(projectile2, getX(), getY()); } }