This site requires JavaScript, please enable it in your browser!
Greenfoot back
JonnyB7
JonnyB7 wrote ...

2016/10/21

Actor not in world error, when bullet touches edge.

JonnyB7 JonnyB7

2016/10/21

#
I keep getting this error... 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:711) at greenfoot.Actor.isTouching(Actor.java:972) at Bullet.hitSpider(Bullet.java:34) at Bullet.act(Bullet.java:19) at greenfoot.core.Simulation.actActor(Simulation.java:604) at greenfoot.core.Simulation.runOneLoop(Simulation.java:562) at greenfoot.core.Simulation.runContent(Simulation.java:221) at greenfoot.core.Simulation.run(Simulation.java:211) This is my source code for the actor class Bullet The weird issue is that the error tells me that the problem is with my "hitSpider()" signature, but the error actually happens when a bullet reaches the edge of the World and is supposed to be removed.
Super_Hippo Super_Hippo

2016/10/21

#
Well, you forgot to add the code, but the problem is probably that the bullet was removed from the world (because it touches the edge) and after that, you are trying to use a method which requires the object to be in the world (for example checking for intersection with a spider).
JonnyB7 JonnyB7

2016/10/24

#
I thought I pasted it to the code section. But yes that was the issue thanks.
You need to login to post a reply.