An interesting problem with enemy health..
quantumsheep
Member Posts: 8,188
Hi all,
Got a teeny problem with my game at the mo'.
Essentially, you have to kill a set number of enemies onscreen before advancing to the next stage.
So, each enemy has its own hitpoint variable called 'health' which goes down by one when it collides with your bullet.
This all works fine - enemy health goes down from 10 to 1, say, enemy is destroyed.
Count how many enemies are dead, go to next scene.
Now I have a level select implemented, and can finish this level, go to the level select, and try it again.
The enemy count works as normal. Kill 5 enemies, move onto next scene.
The problem is, the enemies only take one hit to kill now...
Any ideas why? It doesn't affect my other actors (far as I know), just this particular enemy
Any theories/solutions would be helpful!
Cheers,
QS
Edit: I should add, the enemies are all onscreen at the start of a level i.e. no spawning - their health is a local variable which doesn't seem to be reset, while the global variable (how many are killed) is...
Got a teeny problem with my game at the mo'.
Essentially, you have to kill a set number of enemies onscreen before advancing to the next stage.
So, each enemy has its own hitpoint variable called 'health' which goes down by one when it collides with your bullet.
This all works fine - enemy health goes down from 10 to 1, say, enemy is destroyed.
Count how many enemies are dead, go to next scene.
Now I have a level select implemented, and can finish this level, go to the level select, and try it again.
The enemy count works as normal. Kill 5 enemies, move onto next scene.
The problem is, the enemies only take one hit to kill now...
Any ideas why? It doesn't affect my other actors (far as I know), just this particular enemy
Any theories/solutions would be helpful!
Cheers,
QS
Edit: I should add, the enemies are all onscreen at the start of a level i.e. no spawning - their health is a local variable which doesn't seem to be reset, while the global variable (how many are killed) is...
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
Comments
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
I have a rule at the start of each actor saying: let self.health = (selfhealth*game.difficulty)/game.research
So game difficulty and game research are the only two global variables, and they stay constant.
This changes the health from the base health which is self.health.
I just tried T-shirt's suggestion (brilliant btw mate - should have thought of that!).
The first time you play the health is at 30, as expected.
The second time, it shows just 2.
I HAVE NO IDEA WHY!!! :*(
(and to all the new people here - see, I've been doing this over a year and I *still* get stuck!).
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
No dice. Still changes to '2'.
I tried putting it in a timer too.
Make self.health = 30
Then after .4 seconds make health do the fancy maths bit described before.
Still comes up as 2.
I'll investigate further, but not a happy bunny
QS
Edit: And I've just investigated further and found there's nothing in the level select button that resets the health. Quite right too, as it's not a global variable.
This looks increasingly like a bug to me, which is not good news for the sheep
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
Took the enemies out of the scene, then put them back in - no luck.
Changed the name of the health to 'enemy health' - still no luck.
I'm at a loss, really...
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
All will be revealed soon
I hope you've got a 3GS at least!
Back on topic, I'm going to try spawning them into the level. See if that helps!
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
Hope your spawning works.
:-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
3GS and above only I'm afraid...
And the spawning didn't work... bum!
Not a very productive evening
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
Let me check my variables a second!
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
I just changed the research variable for that of another enemy and it worked perfectly - at least I have an idea where to look now!
Thanks everyone for your help! I'll hunt this bug down
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
BRILLIANT!!!
Seriously, thanks to everyone that tried to help in this thread - it certainly helped me think about how the scoring was working (or not in this case!) and I got it sorted in the end!
As a bonus, going through my actors turned up another bug, but one which would not have been visible till achievements go live in the first update...
Bloody hell. That feels good.
The moral?
TEST TEST TEST TEST TEST TEST TEST!!!!
Thanks everyone, sincerely
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io