Having the hardest time with enemies...

For questions about using Classic.

Post » Mon Jan 31, 2011 7:24 am

So far, I'm having a problem giving them a consistant "explosion" before dying. I thought that generally, most enemies would have the same "death explosion", but a few enmies would have unique ones, like if they were a bird, some feathers would be scattered in the explosion. For a slime, little droplets.

I'm trying this with a test enemy, but I think I must be doing enemies completely wrong. With two of this test enemy, there are numerous problems trying to get some consistancy. I notice that the first instance of this enemy I kill, they just disappear. No death as intended. When I kill the second, there IS a death animation.

I think this is because I've made two of the same collision box, two of the same enemy to paste them to. This is what I think is causing the problem: There's an "Always" condition, telling the enemy to stick to the collision box's XY position. When the first enemy dies, instead of playing the death animation, it goes to the next available collision box, hence the instant disappearing.

Is there a better way to handle enemies so I can give them their own death animation, or should I create a seperate object for the death animation? And just have the enemy spawn that when health reaches 0? I'm assuming it might be best to create a seperate object for death animation, huh?
B
4
S
2
G
4
Posts: 164
Reputation: 1,878

Post » Mon Jan 31, 2011 3:17 pm

Separate object for death animation seems to be about the best option available.

I have sounds playing when mine die, but now that I am going to have different monsters I have different animations set for different monsters. You could always import an animation to the enemy sprite, and have a death animation trigger on death.

Should work just as good as long as you are using private variables correctly.
B
2
G
1
Posts: 8
Reputation: 466

Post » Mon Jan 31, 2011 7:39 pm

I use a private variable called 'state' for things like this.

State 0 for me usually means it just spawned, so I have a For Each, if state == 0, do setup things here. Then I switch the state.

For you, just set the state to -1 or something if it's supposed to die, and have a if state == -1 and death animation is not playing, play death animation.
B
3
S
1
G
4
Posts: 37
Reputation: 1,299

Post » Mon Jan 31, 2011 9:59 pm

I actually tried an experiment of "states", seeing some other games use that for characters and enemies before. It didn't seem to make any difference. I also used a "If Defeated animation is NOT playing" condition for "Stick Enemy to Collision Box XY", but that didn't work either. The sprite still seemed to stick to the nearest collision box.
B
4
S
2
G
4
Posts: 164
Reputation: 1,878


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests