Tracking Multiple Instances

Get help using Construct 2

Post » Wed Apr 03, 2013 9:37 am

Apologies if this has been answered out there, I have looked, a lot and have not been able to find anything that fully explains what I'm after.

My basic problem is keeping track of everything relating to an enemy instance, for example:

I have 10 instances of an enemy spaceship each one having:
health bar
shield
projectiles
a vision cone

What is the best way for making sure that when something happens to one of these objects I can relate it back to the right enemy?

I currently have everything in a container which is working for the health bar(which scales its length based on an instance variable on the enemy), however, when info goes the other way it applies to everything, for example:
Enemy vision cone collides with the player, firing event triggers for all instances.
Player projectile hits enemy shield, shield strength variable is decremented for all instances.

I thought something to do with assigning the same ID to everything in the container on create might work but I can't work out how to do the check like:
on collision
vision cone ID = 34
-> Enemy ID = 34 -> Spawn bullet

I hope this makes sense, I'm not too experienced yet but I figure this would be really helpful to nail as early as possible so I can get my core gameplay up and running.
B
5
Posts: 14
Reputation: 403

Post » Wed Apr 03, 2013 12:13 pm

If you post a simplified capx we might be able to help you a lot faster - what you are doing seems fine to me.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Wed Apr 03, 2013 12:46 pm

You can do it with two conditions: if vision cone touches something AND vision cone id is the same as enemy id, fire bullet. The event sheet will select instances that match the condition and you can associate vision cone and enemy that way, with a variable that's going to be the same.
B
19
S
6
G
1
Posts: 116
Reputation: 2,730

Post » Tue Apr 09, 2013 9:23 am

Thanks for the quick replies guys, sorry I have been so slow :( Computer troubles.

I should be back up and running tonight so I'll try tidy it up and post a version on here.

Good to know I'm on the right track though.
B
5
Posts: 14
Reputation: 403

Post » Fri Apr 12, 2013 4:05 pm

This actually just worked straight up, my problem was that for some reason I had the enemy ID check nested underneath the vision cone check.

Thanks for the help guys, you got me past a very frustrating problem.
B
5
Posts: 14
Reputation: 403


Return to How do I....?

Who is online

Users browsing this forum: jobel, Yahoo [Bot] and 21 guests