I've include a picture of the error and my code for the enemy... sorry i know its alot of code but didn't have another way...
The error reads as follows
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.
at greenfoot.Actor.failIfNotInWorld(Actor.java:681)
at greenfoot.Actor.getOneObjectAtOffset(Actor.java:885)
at Porcubutt.move(Porcubutt.java:62)
at Porcubutt.act(Porcubutt.java:40)
at greenfoot.core.Simulation.actActor(Simulation.java:583)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:541)
at greenfoot.core.Simulation.runContent(Simulation.java:215)
at greenfoot.core.Simulation.run(Simulation.java:205)
public class Porcubutt extends Characters { private GreenfootImage imageR; private GreenfootImage imageL; private int Health = 1; private boolean IsAttacking = false; private int stillAttacking = 100; private int spriteHeight = getImage().getHeight(); private int spriteWidth = getImage().getWidth(); private int lookForEdge = (int)spriteHeight/2; private int lookForGroundDistance = (int)spriteWidth/2; private int speed = 2; private int direction = 1; //-1=left 1=right public int kills = 0; private int SBHealth = 90; public Porcubutt() { imageR = new GreenfootImage ("PorcuButt_R.png"); imageL = new GreenfootImage ("PorcuButt_L.png"); } /** * Act - do whatever the Enemy wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { SirBAlert(); checkAttack(); move(); } public void checkAttack() { if(Greenfoot.isKeyDown("space") && stillAttacking >= 50 ) { IsAttacking = true; stillAttacking = stillAttacking -1; } else { IsAttacking =false; if (IsAttacking = false && stillAttacking < 100 ) { stillAttacking = stillAttacking +1; } } } public void move() { Actor ground = getOneObjectAtOffset(lookForEdge, lookForGroundDistance, Platforms.class); if(ground == null) { speed *= -1; // Reverses direction lookForEdge *= -1; // Looks for a negative number } else { setLocation (getX() + speed, getY()); } if (speed == 2) { direction = 1; setImage(imageR); } else { direction = -1; setImage(imageL); } } public void SirBAlert() { if (canSee(SirB.class)) { checkSirB(); } } public void checkSirB() { if (IsAttacking == true ) { Greenfoot.playSound("Squeak.wav"); Health --; } else { SBHealth =SBHealth-15; Greenfoot.playSound("Hurt.wav"); } if (Health <= 0) { getWorld().removeObject(this); } if (SBHealth <= 0) { Greenfoot.stop(); } } public boolean canSee(Class clss) { Actor actor = getOneObjectAtOffset(0, 0, clss); return actor != null; } public void setSBHealth(int SBHealth) { this.SBHealth=SBHealth; } public void setIsAttacking(boolean IsAttacking) { this.IsAttacking=IsAttacking; } public void setStillAttacking(int stillAttacking) { this.stillAttacking=stillAttacking; } public void setKills(int kills) { this.kills=kills; } }