How do I pick by priority

  • Hi everyone,

    Basically i can't manage to pick objects depending on their role. So here is my little problem, I want to pick Characters with Role 1 in priority, and if none are available, then pick Characters with Role 2. I can't get this to work with Else Shall I instead use a variable Characters.Count < 0 to determine the availability of Role 1? or There is another way round with Else?

    How would you do it?

    Thanks for your help!

  • You should be able to do it with Else

    This should definitely work

  • Thanks monitz87!

    Let's say that everytime I press 5, the character's opacity changes to 50. I want characters with role 1 first then those with role 2 to be affected. That is not going to work is it? I need an extra condition to check there is no character left with role 1at 100 opacity for the else to work right?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can use the Object.PickedCount expression after you compare Object.Role = 1 to see if there are 0 objects with a value of 1 for Role

  • Add Opacity=100 to event 1.

  • Add Opacity=100 to event 1.

    this

  • Thanks everyone! I'll try this tonight when I'll get back home

    Basically, I'm trying to build an AI which is going to extinguish fires depending on their roles. Guys with roles 1 should be the first one to move to stop the fire, and guys with role 2 should only go there if guys with role 1 are all busy trying extinguishing the fire

    Hopefully I'll manage to do it with your advice.

  • Right so I did what you were suggesting with opacity as condition for instance:

    EncryptedCow

    I did not manage to do something equivalent using your method. And since I'm always interested in in trying different alternatives, I would be interested to see that working with your suggestion. I have attached the file so you don't need to do it from scratch if you have the time

    In the meantime, thanks for helping sorting this out. Now I need to reproduce it on a larger scale

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