Using enters scene and leaves scene to keep a count - flaky :(

sparkyidr

  • Posts: 48
I have an event (as part of a scene behaviour)that says

when actor of type (my chosen actor) enters the scene
set "goodies count" to goodies count +1


I also have an event that says
when actor of type (my chosen actor) leaves the scene
set "goodies count" to goodies count -1



If I put 5 actors in my scene and start the scene, goodies count shows as 5.. nice.
But, as the actors leave the scene, sometimes it does the "-1" from goodies count, and sometimes it doesn't.
And it feels fairly random.

Sometimes it only does the -1 one time.. other times it does it 4 times...and sometimes 3... but never all 5

Any ideas? the logic seemed pretty good to me.

Future Freak

  • Posts: 413
How about having 4 regions - or actors on each edge of the screen and using a collision to update the counts as they go off screen?

sparkyidr

  • Posts: 48
I did it the other way around.
I created a region that covers most of the play area, and changed my events to trigger when the actor type enters of leaves the chosen region....

and that seems to work.

Feels like overkill/a workaround, when the "enters or exits scene" event already exists though.

Future Freak

  • Posts: 413
Do these actors have continuous collision detection on them (as in bullets?)  Maybe they're moving too quick and missing a frame where they are detected as leaving - hence the discrepancy?

sparkyidr

  • Posts: 48
Yeah.. I already checked that.. and it's set to on. (which I assumed was the best way for it to be)

Like I say, it's working with the region work around...which in theory does the same thing re: timings
?

Rexasul

  • Posts: 147
Have you tried:

my website |>>| shadowlabs.net

sparkyidr

  • Posts: 48

Rexasul

  • Posts: 147
This is my first time using Stencyl 2.0, and it's really racking my brain. If you set it so that when the actor exits screen it sets the goodies count to 100, you'll see that it still stays the same (at least for me it does, using the console). It seems like it's not detecting the "exit" at all, it could be a bug but I don't have enough experience with 2.0 to tell. Sorry I can't be of more help.
my website |>>| shadowlabs.net

Nomosoft

  • Posts: 122
Do you have "make Self always active" on your Actors? Otherwise, when they leave the screen, they stop processing behaviors.

sparkyidr

  • Posts: 48
Well.. I just re-created the scene and actors etc, and now it works

It's poss I DID forget to "always simulate"....but I was sure I did.

Anyways.. I obviously had something wrong, as it's working as expected now.