Tracking Multiple Instances

0 favourites
  • 5 posts
From the Asset Store
Be quick and choose the right answer for the shown equation.
  • 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.

  • If you post a simplified capx we might be able to help you a lot faster - what you are doing seems fine to me.

  • 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.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)