Problem with multiple enemies?

Get help using Construct 2

Post » Wed Jan 08, 2014 10:19 pm

Basically I have a hit box for my enemy and a separate sprite whose position is set to that box on every tick to represent it (I'm under the impression that it's better practice to do this for collision than to use the actual sprite).

So, when the enemy is attacked, I switch an instance variable ("dead") from 0 to 1. Then I have a separate event that runs when the dead variable is 1 (true) to animate the enemy exploding and that destroys both the enemy hit box and the sprite that represents it.

The problem is when I have multiple instances of the enemy, if one of them is attacked, all of them are triggered to die. Do I need separate variables for every instance? How do I do this without creating a big series of events for every single instance of an enemy? Should I not even be using a variable?

Thanks in advance for any help!
B
5
S
1
Posts: 15
Reputation: 341

Post » Wed Jan 08, 2014 10:31 pm

If you put the enemy and the hitbox to a container, this could solve everything.

another option is to pick the right enemy sprite in the event, so the action is not called on all instances of the enemy sprite.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Jan 08, 2014 11:47 pm

Any tutorials on containers? I'm not sure at all what that is. Thanks!
B
5
S
1
Posts: 15
Reputation: 341

Post » Thu Jan 09, 2014 2:26 am

I think that you have not seen the event sheet for ghost shooter. Why don't you take a look at it via

new >template ghost shooter


you should just remodel what you need from that. Containers are not
necessary if your doing something simple. Eastcr9w2014-01-09 02:29:31
B
8
S
3
Posts: 6
Reputation: 836

Post » Thu Jan 09, 2014 8:07 am

Containers might not be necessary, but learning about them in an easy game is better than not knowing about them when trying to create something harder.

When working with a hitbox and seperate sprite for the enemy it is easier when the sprite and hitbox are "connected" so when you destroy or hit one the other one is automatically "linked", it makes the picking part, which many construct2 users confused, a little easier.

Here's the manual entry on containers

If you put the enemy sprite and the hitbox together in a container, when you say on collision with hitbox, enemy play death animation, only the "linked" enemy will play that animation.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 29 guests