Is there a way to prevent "off screen" creation of Actors?

infinitum3d

  • Posts: 89
In the Actor Events, I have;

When SELF is KILLED
set NUMBER to (NUMBER - 1)  <-- NUMBER is a Game Attribute
Create POWERUP at ACTOR X,Y  <<-- POWER UP is a new Actor

So this works fine when a bullet kills the actor on screen,
but when the Actor exits the screen NUMBER stays the same.

My assumption is that either
A) SELF is not being killed, which is unlikely because it works without the CREATE part, or
B) It is CREATE-ing a POWER UP off screen. More likely, but is that possible?

I've tried adding the Behaviour DIE ON LEAVING SCREEN to my POWER UP, hoping it would be instantly killed upon creation, but it still doesn't work.

Any suggestions?

Thanks!

iNK

  • Posts: 68
Hi there; to be clear, you have a player that, upon death, changes a game attribute. Problem being that when the player goes off-screen, that attribute doesn't get changed, and the power-up doesn't spawn. If that's so, have you tried using a print statement to make sure the 'When self is killed' script runs?

Something else that might be happening is that (depending on how you made your power-ups work) the power-up is created and grabbed while 'self' is still being killed (after all, self can't execute code if it's non-existent, so some remnant still remains).

Edit: Just tried this out for myself. Seems like print statements work, but creation of a new actor doesn't.
I tried spawning an actor from the 'when killed' script and attached a print script to the new actor upon creation, which didn't print.
Also tried using a 'do after' block, which didn't work. So it seems you only have time for a print block to execute before the actor kills itself and the rest of the code in the 'when self is killed' block gets destroyed.

So perhaps you could do something other that kill the actor right away; for example, trigger a custom event, and then have that change the attribute and spawn the power-up, then kill self.

« Last Edit: June 05, 2014, 08:05:55 pm by iNK »

infinitum3d

  • Posts: 89
Hey, thanks! I appreciate the help.

"to be clear, you have a player that, upon death, changes a game attribute."


Yes.

"Problem being that when the player goes off-screen, that attribute doesn't get changed, and the power-up doesn't spawn."

If I remove the SPAWN portion, the attribute does get changed. But if I include the SPAWN portion, the attribute does NOT get changed. And since its happening offscreen, I don't know if the SPAWN is occurring or not.

"If that's so, have you tried using a print statement to make sure the 'When self is killed' script runs?"

I have not tried that. Thank you for the test.

"Edit: Just tried this out for myself. Seems like print statements work, but creation of a new actor doesn't.
I tried spawning an actor from the 'when killed' script and attached a print script to the new actor upon creation, which didn't print."

Interesting. If I kill the actor on-screen, then the POWER UP creation occurs as expected. I wonder why it doesn't work off-screen. I'm assuming the KILL ON LEAVING SCREEN behavior immediately kills the actor and does not allow other scripts to be executed.

Hmmm... I'll have to figure out a work around.

sdieters

  • Posts: 2068
I will read trough your question when in home again. This can't be such a big of a problem.
My new profile is TheIndieStation.
When you see a recent post with this name, i'm probably using my phone. So dont mind any typo's =p