Error #1009 after killing actor [Solved]

fatsomania36

  • Posts: 15
I am making a space invaders game very similar to the tutorial on this site. I am trying to make it so when the ship enters a region, the alien ship it's in front of shoots it.  I have it set so if the alien ship is alive, every second it shoots a  bullet. For some reason when it dies, though, I get this error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
   at MethodInfo-6538()[Source/scripts/SceneEvents_0.hx:121]
   at com.stencyl.behavior::TimedTask/update()[C:/Program Files (x86)/Stencyl/plaf/haxe/lib/stencyl/1,00/com/stencyl/behavior/TimedTask.hx:48]
   at com.stencyl::Engine/update()[C:/Program Files (x86)/Stencyl/plaf/haxe/lib/stencyl/1,00/com/stencyl/Engine.hx:2373]
   at com.stencyl::Engine/postUpdate()[C:/Program Files (x86)/Stencyl/plaf/haxe/lib/stencyl/1,00/com/stencyl/Engine.hx:2618]
   at com.stencyl::Engine/onUpdate()[C:/Program Files (x86)/Stencyl/plaf/haxe/lib/stencyl/1,00/com/stencyl/Engine.hx:2611]

I am telling it to only fire a bullet if the alien ship is alive, so I don't know why I am getting this error. It seems like it's ignoring that. Here are my blocks:



I tried doing this as well, but I still got the same error.


« Last Edit: February 08, 2017, 12:06:35 pm by fatsomania36 »

TheIndieStation

  • *
  • Posts: 2263
There is probably another attribute in another script that holds a reference to the actor that you killed.

morphman86

  • Posts: 141
You're telling it to start the loop if the enemy ship is alive, but you're never telling it to stop the loop, so it will continue to do it forever. There's a block to stop the loop, you could put that in the top of the loop in a check if the actor exists and surround the rest in an otherwise block.
Programming equivalent of Jack-of-all-trades

TheIndieStation

  • *
  • Posts: 2263
Ah I totaly missed that loop. I thought it was an after loop (using my phone atm hehe).
What you can do instead is using a custom event that repeats itself every 1 second, but only then the player is still alive. This get's rid of the infinite loop of a "do every ..." loop, and is easier to controll

fatsomania36

  • Posts: 15
Ah I totaly missed that loop. I thought it was an after loop (using my phone atm hehe).
What you can do instead is using a custom event that repeats itself every 1 second, but only then the player is still alive. This get's rid of the infinite loop of a "do every ..." loop, and is easier to controll
I did just what you said before you said it. It worked! Thanks for the help everyone.

fatsomania36

  • Posts: 15
OK, now, after fixing a problem where the enemy ship kept firing even if I wasn't in Region 15, this problem is back. I'm still using a behavior, but now the game glitches again once the ship is killed. Does anyone know what to do?


LIBERADO

  • *
  • Posts: 2704
Does anyone know what to do?
Yes. In a "when created" event, store the Enemy Ship in a actor attribute, then select this actor attribute in the "[Actor] is alive" block. This way it will work.
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

fatsomania36

  • Posts: 15
Thanks for your help! It worked.