Does this make sense to you?
Hello! I'm having problem with this zombie game I'm trying to make. The problem comes when I try ti kill them its pretty odd cause this made a lot of sense to me. Maybe I did something wrong but this is what I did.
I crated a self (Integer attribute) & I named it kill me. I want the zombie to die after 2 hits from a bullet. So I said
- Rule:
- If self.killme >= 2
- Do destory this actor
- Then I made Rule with a Timer in it I said
- Rule:
- If self.killme >= 2
- Timer:
- After 0.1 seconds
- Change attribute self.killme to 0
- Then I made a collide behavior I said
- Actor overlaps or collides with Bullet
- Do:
Change attribute self.killme to self.killme+1
That made complete sense to me but for some reason it doesn't die with 2 bullets. Sometimes the zombie does with 2 bullets sometimes it takes more than that. And that's messing up my point keeping system. Does this make sense to you, is there a better way to making this work?
(I made this up in my head & I've been using gamesalad for about 6 months so I'm no pro LOL unlike you guys)
Comments
What are steps 5-9 supposed to be doing?
In steps 1-3 you're telling the actor when to die - when it has been hit by 2+ bullets. In steps 10-13 you're getting the actor to detect when it has been hit by a bullet, and increment the number of hits by 1. Those both make sense - and should work.
The rule you mention in steps 5-9 shouldn't get triggered. When self.killme is 2, the actor will be destroyed, so the timer will never start and self.killme won't get reset to 0 (as it has been destroyed).
If you have "run to completion" checked in the timer, GameSalad might be delaying the destroy until after the timer has completed - which would mean self.killme would be set to 0 again and the actor would need 2 more bullets to destroy it. GameSalad doesn't always process things in the same order every time, so it might sometimes get the destroy off before the change attribute, and sometimes not.
Does the behaviour change if you remove that rule? And what happens when you put a Display Text in the actor that shows the current value of self.killme? Knowing that will help you pinpoint your problem. If it increases to 2 and your actor doesn't get destroyed, your problem lies in the destroying. If it gets hit by a bullet and doesn't increase in number, your problem probably lies in the collision detection/action.
Be sure to also check that you haven't accidentally unlocked anything on the scene.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
@Armelline So I should get rid of step 5-9 completely? & the reason I put that is that so self.killme is set back to 0. I tried to do it with out the timer but the zombies weren't spawning because when it get's over 2 hits Gamesalad thinks it should just destroy the rest of the zombies, because of what I said in step 1-3. So the reason I have step 5-9 is to rest it back to 0 so the spawner can spawn the rest of the zombies. (If I don't have 5-9 the self.killme will just keep going up every time a bullet collides with a zombie actor.)
@http_gamesalad -- Yes, get rid of them completely. As @Armelline said, the zombie actor destroys itself, and so its self.killme is destroyed with it. No need to try change it to anything anymore.
The self.killme will not keep on going up every time a bullet collides with any zombie actor. A self attribute can only be seen and affected by the actor itself. So when a zombie gets hit, only the self.killme inside it gets +1, the self.killme attributes in all the other spawned zombies stay as they are.
That's the important difference between self and game attributes.
Just one problem. If you have spawned 5 of these same actors and shot and killed one they will all destroy.
@Speedy007 -- Why?
@Speedy007 @pHghost Uh no I didn't run into that problem bro. It spawned all 10 from all different sides of the spawner but I did come into a problem. I want to display the amount of zombies you've killed so I made an interger attribute called game.HowManyLeft and I put it in rules 1-3 but it isn't counting properly. It like counts like 15 when I only spawned 10 zombies. I only want it to count when a zombie is killed and +1 in it every time.
So in rules 1-3 I just simpply added
change attribute game.howmanyleft to game.howmanyleft+1
So shouldn't that only and one when self.killme is >= to 2
If you had one actor set to die after number reaches its rule and you spawned 5(any number) of those same actors then they to would die...Say i made a balloon and said for it to change its size when integer is 1...Then i have a rule set up that when a actor collides with that balloon it would change that integer to one...Now say i copied those balloons and placed them around the map. When that actor hits one balloon its going to change that integer to 1 and since all the balloons where set up the same all will change size...even though the actor only hit the one balloon...
This is simply not true. We are talking about an actor attribute.
>
>
Oh crap!!! Cool dude, wasn't even paying attention there... I kinda get lost in those big posts...lol... Man if this post would of happened sooner it would have saved me quite a few hours...Thanks, i will try to remember that on my next game.
@http_gamesalad -- make sure you add +1 only when the zombie is dying, not when it is hit, if it is misbehaving.