Game picking the wrong instances despite UID used

0 favourites
  • 5 posts
From the Asset Store
Act on your instances, get/set their properties and variables only thanks to their UID. No more picking trouble! Plugin
  • Hello everyone,

    I am working on a prototype that has a family called "Enemies". This family has about 5 different enemy types.

    The enemies have AI but given the common nature of their behaviors I am using families to filter which ones to apply different AI state actions to.

    The below events pick enemies based on who finishes the attack animation:

    https://i.imgur.com/1eJNKM3.png[/img]

    Note I pass the UID of the enemy to filter with it.

    Next I start classifying enemies based on what type they are and forward the UID to the final attack action function:

    https://i.imgur.com/2IY1DMJ.png[/img]

    Finally, I pick the enemy based on the UID passed and do the attack action (namely spawning an effect):

    https://i.imgur.com/wwYfed7.png[/img]

    The issue I am encountering is that despite picking the specific enemy using its UID, the effects spawn at a single enemy's location instead of at each of the enemies.

    Moreover, when I change the first screenshot's condition "On Attack Animation Finished" to include "For Each Enemies" to make sure that the event loops over every single enemy instead of one only, it doesn't fix the issue. The same issue happens.

    Does anyone have any idea what is going on here?

  • The middle function doesn't pick any Enemies instances and i'm not sure the need for it or what's happening in there. You need 3 functions to run an attack? It's a bit convoluted just put it in one function then nothing can go wrong.

  • The middle function doesn't pick any Enemies instances

    That is correct, its job is to decide what kind of enemy we are referencing (melee, ranged, kamikaze, etc...) and forward the UID to the function that does the attack.

    and i'm not sure the need for it or what's happening in there. You need 3 functions to run an attack? It's a bit convoluted just put it in one function then nothing can go wrong.

    I am trying to divide the "code" so it isn't all in one function so it is easier to maintain. Having one massive function that checks every single enemy type + their attack pattern is going to be super messy. Not to mention bosses.

    The way it is setup, I have the common stuff in one event page. This one event page forwards to 5 separate pages that belong to each type. Each type then picks the specific sub type to do the action.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You run through the functions and end up with 'if EnemyBasicMelee' then do an attack. You could just use this as the only condition and scrap the other functions.

    Also one other thing to note you don't need to forward a UID anymore, you can use the 'copy picked' option in the function, if you tick this then it keeps the picked Enemies instance. Also I disagree about the 'messy' code, I would keep it all in one function when it's simple enough.

    edit :

    And to fix this original problem you need to send through the variable in the second function, so instead of Enemies.UID it is enemyUID the variable.

    And another thing I just noticed your timer in 2nd function also won't work well as it will not pick an Enemies instance, that needs a condition like pick where UID = enemyUID unless you use the copy picked method I mentioned above.

  • You run through the functions and end up with 'if EnemyBasicMelee' then do an attack. You could just use this as the only condition and scrap the other functions.

    Sure that might work, but let's say you're doing this for 20 enemies. Some of these are slightly similar but different some ways (i.e. heavy vs light melee) it would quickly get messy. But maybe I am wrong, I'll try it out.

    Also one other thing to note you don't need to forward a UID anymore, you can use the 'copy picked' option in the function, if you tick this then it keeps the picked Enemies instance. Also I disagree about the 'messy' code, I would keep it all in one function when it's simple enough.

    edit :

    And to fix this original problem you need to send through the variable in the second function, so instead of Enemies.UID it is enemyUID the variable.

    Amazing catch, thank you very much. That definitely fixed the issue!

    I didn't know about Copy Picked. I just read about it and that is an amazing feature, wish I learned about it earlier. This simplifies my setup quite a bit

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