Seperate turret behaviours for different targets?

0 favourites
  • 5 posts
From the Asset Store
This music pack covers differents situations for visual novels, anime games and many more!
  • Hey everyone,

    I'm trying to set up a simple AI with multiple Turret behaviours on one object. But the behaviours don't seem to make a difference about what target type gets into which behaviour's range.

    I want my little dude to approach my player when in range and in another behaviour attack an enemy when in (another) range. But with the attack range being larger and therefore triggering first, my little dude just attacks the player upon getting in range.

    Any idea how I could keep the two behaviours seperated?

  • Any ideas anyone?

    I read about IIDs and UIDs but have no idea what to make of those ..

  • [quote:3otdpidt]Any ideas anyone?

    I read about IIDs and UIDs but have no idea what to make of those .

    I never use IIDs my self only UIDs, never really found a reason to use the IIDs. But UID are just a unique identifier for a given object. Which make it very easy to manipulate specific items. You could do something like it manually if you wanted, but C2 just does it for you automatically, so you don't have to, which is why its easy to use.

    But imagine that you are in a dark room with two other people and you cant see each other. But you have to give one of them some instructions. The normal way would be to say there name and then what you wanted them to do,

    "Roger come to me" in this case Roger is the UID. Even if they both are called Roger, you might use Roger A or Roger B so they know who you are talking to. So no matter what they can never have the same name.

    Here is an example of how to make behaviours for turret this is from a former project I did:

    It shows two different turrets a basic "gun" turret and a turret that slows enemies. From the description in the image it explain overall how they work.

    The Gun turret

    Uses a very simple behaviour it will just shoot the first enemy with the lowest health that are within range.

    Since all the turrets are part of the Family "fTurret" I use an identifier "Turret_type = "Gun" to make sure that this behaviour only apply to gun turrets. Then I make sure that it only do this for turrets that doesn't currently have a target.

    Since im not sure how many turrets it picks based on these conditions and don't really care to know. I throw in a "for each" in the end so it does it for all of them.

    Then I make each of the turrets pick the enemy with the lowest health and set it to the turrets target. And it start all over once that enemy is dead or outside range.

    The Slow turret

    The first part is about the same as with the gun turret, except I don't really care if the slow turret already have a target. I want it to keep slowing enemies that are currently not slowed. And again I don't know how many turrets it picks so I throw a "For each" in there again. Since in my game an enemy can only be slowed if it have no shield, I make sure that the enemies shield are equal to 0, and that they currently aint slowed, which is just a Boolean that is switch on/off (there is a bit more to it.) And last it picks the one nearest to the turret.

    And when that is slowed it start all over.

    So if you want to use several different behaviours for the same turret, you can just make a Boolean that you switch for each of them, that also need to be true.

    For instant for the gun turret, I could have made it pick the enemy with the highest amount of health, if some Boolean have been set to that. So you can make it like that.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • where's my reply gone? anyway, repeat:

    sounds like a good approch, to check tags, but for that I'd have to get info from my turret's targets. Is it possible to reference those? Can I fetch my current target's variable data?

  • Yeah you can do that as well, you can get the Target.UID of a turret, so you can use that to pick it, and then you have access to all you need.

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