How do I get Turrets to ignore specific instances

0 favourites
  • 6 posts
From the Asset Store
10 turrets rendered in 3D with top down and menu views. Three upgrade levels per tower.
  • Hello All,

    I have a 4 player game - players can each summon turrets.

    These turrets of course have the turret behavior and on created have "ADD TURRET TARGET > PLAYER"

    Turrets have the target mode set to nearest

    Turrets have an instance variable that stores the UID of the player that created them.

    I don't want turrets to target the player that created them. So I have an event -

    Turret > on Turret Target acquired - set Target to "self.turret.TargetUID"

    - Turret.Target = Turret.CreatorUID > Turret - Unacquire Turret Target.

    What I run into is that when the player that created the turret is the nearest Player instance the Turret does nothing. As soon as the player that created it moves out of range it will properly acquire another player and fire. But as soon as its creator becomes the nearest target it once again does nothing.

    I guess to simply my question: Is there any way to tell a turret to ignore specific instances of its given target object?

    Thanks!

  • Create an instance or family variable for example 'exclude'. Pick which target to exclude or clear from target list by set 'exclude' variable to true. That way turrets won't aim the excluded instances.

  • All of the players are an instance of the player object. I only see a way to set a turrets target to a specific object, and no way to filter instances.

    I've done something similar to what you've suggested Aelxtro but it's not truly skipping the player who created it its simply acquiring and unacquiring the player that created it when its the closest player object. But is there a way to have it ignore an object instance entirely?

    Thanks

  • Pick turret

    Pick its target by UID

    Pick new target using a family

    Unacquire target

    Acquire new target (or it might retarget the in acquired one)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So I tried this -

    and i get this error when the player that created it (the one that I want it to ignore) is the closest target.

    Is this a bug? The Turret behavior specifically says "Unacquire target

    Tell the turret to forget its existing target, even if it is in range. This frees it up to target a different object, but it may choose to immediately target the same object again unless the Acquire target action is used immediately afterwards.

  • On turret target acquired is a TRIGGER. This means, when 'it' happens, the event runs. How to explain.

    Say you have 5 events and event nr 3 is a trigger. You could think they run sequentially. First event 1, then 2, then 3, then 4, then 5 .... and again 1. But the trigger happens when 'that thing happens' where it is designed for. No matter wich event is running, event 3 will run, when triggered.

    As a result, at that one moment a target is acquired it runs, and if you force it to acquire a new target in the same event, it runs again, and again, and again. Because that is what you want it do. It is, in fact, CALLING itself. So, after a while, this CALLING itself, exceeds the CALL STACK.

    Say, you code something like .... on the moment i open a door ... do this. And this 'do this' is: open a door. At that moment the 'on the moment i open a door' kicks in. Because that is what you just did, open a door. This is calling itself.

    Sorry, it is so evident to me, and so difficult to explain.

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