Most efficient way to give bonus for kills in a time period?
TomCoffee
Member, PRO Posts: 175
Hi... working on my first "game" and I'd like to award a bonus if 3 or more bad guys are killed in a 1 second period.
What's the most efficient way to do something like this? All 3 bad guys would be different actors... Thought about something like this:
Have 3 attributes recording the millisecond that a guy is killed (Kill1, Kill2, Kill3).
Have 1 attribute as a Counter (1, 2, or 3).
When a guy is killed it pops the millisecond in Kill1 and increments the counter.
When another guy is killed it fills in Kill2 and increments counter.
Same with 3rd kill.
Then have a check which runs and says: "If Kill3-Kill1 < 1 then BONUS!"
Or is that too fast/too inefficient for GameSalad?
Thanks!
What's the most efficient way to do something like this? All 3 bad guys would be different actors... Thought about something like this:
Have 3 attributes recording the millisecond that a guy is killed (Kill1, Kill2, Kill3).
Have 1 attribute as a Counter (1, 2, or 3).
When a guy is killed it pops the millisecond in Kill1 and increments the counter.
When another guy is killed it fills in Kill2 and increments counter.
Same with 3rd kill.
Then have a check which runs and says: "If Kill3-Kill1 < 1 then BONUS!"
Or is that too fast/too inefficient for GameSalad?
Thanks!
Comments
Timer every 1 second
.....Change Attribute game.killStreak to 0
When game.killStreak ≥ 3
.....[award bonus]
And in your enemy actor:
When [condition for dying; e.g. collides with bullet actor]
.....Change Attribute game.killStreak to game.killStreak+1
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
So you would use a timer? Definitely easier than fiddling with device microseconds. I've read so much about "optimizing" GameSalad that I think I've gotten a little paranoid about optimization... Thanks!
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User