How do I get Turrets to ignore specific instances

Get help using Construct 2

Post » Thu Jun 23, 2016 5:50 pm

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!
B
3
Posts: 7
Reputation: 189

Post » Thu Jun 23, 2016 8:09 pm

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.
ImageImage
B
108
S
49
G
23
Posts: 783
Reputation: 22,611

Post » Thu Jun 23, 2016 8:52 pm

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
B
3
Posts: 7
Reputation: 189

Post » Thu Jun 23, 2016 8:57 pm

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)
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Jun 26, 2016 5:25 pm

So I tried this -

Image

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

Image

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.
B
3
Posts: 7
Reputation: 189

Post » Sun Jun 26, 2016 5:59 pm

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.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 44 guests