When self exits the screen... nothing happens??? SOLVED

infinitum3d

  • Posts: 89
I have a Game Attribute (number) drawn to the screen.

Created-> set GameAttribute to 10.

so far, so good

When my enemy leaves the screen, I want to decrement the number.

When (enemy) exits the screen
set GameAttribute to (GameAttribute -1)
kill self after leaving screen



This doesn't decrement the variable. Any ideas?

« Last Edit: January 19, 2014, 06:52:05 am by infinitum3d »

Electric Fruit

  • Posts: 116
Do you have the enemy set to "always active"?. If not all the objects behaviours are disabled when it leaves the screen.

infinitum3d

  • Posts: 89
No. I didn't. 

So:

when created
make (self) always active
?

Thanks! I'll try it.

UPDATE: Hmmm... Didn't work.   I also tried adding the event
when enemy killed
set game attribute to game attribute -1

doesn't work either.

« Last Edit: January 15, 2014, 03:36:01 pm by infinitum3d »

Photon

  • Posts: 2691
Can you show the code/behavior you are using please?
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

Electric Fruit

  • Posts: 116
I knocked up a quick prototype in which I got something similar to work using the following code;

Behavior attached to object or "enemy"

When Created

Make self always active

Updated

If [Self is on screen] = [false]
Set [Game attribute] to [Game attribute -1]
Kill [Self]

With this I was able to move an object off the screen and have it reduce the attribute.

If you are still having trouble it may be helpful to show us a screen shot of the behavior or code your are using (as Photon said).


mat0pad

  • Posts: 364
Or one could do it like this and avoid FPS problems in the future:

Event > created:

Make self always active


Event > when self exits screen:

if [self is alive]

Set [Game Att.] to [Game Att - 1]

Kill self
   


                              

infinitum3d

  • Posts: 89
I'll try both of these.  I was hoping to attach it to the scene rather than the enemy since I have multiple enemy actors in a group.  I thought if I could set the decrement whenever something from the Group was killed it would be more efficient.

Thanks! I'll keep trying.

infinitum3d

  • Posts: 89
Maybe it has something to do with my When Drawing because the Game Attribute will start at say. .. 10. An enemy goes off the screen. The number is still showing 10. Then I shoot the next enemy and it changes from 10 to 8, which is correct. One went off screen and one was shot.

How often does the When Drawing refresh? Can I force a refresh?

sdieters

  • Posts: 2068
Try this:

Create a scene event like this.

IF member of (enemy group) leaves screen,
Set game attribute to game attribute -1

it was the first that came to mind haha =P
please let me know if it works.
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

infinitum3d

  • Posts: 89
So try IF rather than WHEN? It's worth a shot.

infinitum3d

  • Posts: 89
Maybe it has something to do with my When Drawing because the Game Attribute will start at say. .. 10. An enemy goes off the screen. The number is still showing 10. Then I shoot the next enemy and it changes from 10 to 8, which is correct. One went off screen and one was shot.

How often does the When Drawing refresh? Can I force a refresh?

Bump. Can I force a refresh to When Drawing?

amadeus111

  • Posts: 17
try these
locate inc/dec block in numbers&text

 when actor leaves screen
  dec(attribute) by 1 or however you want

infinitum3d

  • Posts: 89
@Photon- Thanks for the post. I can't show a screen shot because I can only post from my phone. I really wish I could. 

@sdieters- Thanks for the help, but yeah, that was the first thing I tried too.

@amadeus111- Thanks for the help. I tried that. It doesn't seem to work for me.

@ElectricFruit- Thanks for the reply. I'm still trying.

@matt0pad- Thanks for your help.

I'm going back through now to check all my blocks. I must have missed something.


UPDATE: Yeah, so, I'm just careless. I had my "kill when leaves screen" in a second block BEFORE my decrement event. It was killing the actor before decrement could occur. I've got it fixed now.  Thanks all!


« Last Edit: January 19, 2014, 06:51:29 am by infinitum3d »