I'm wondering how to use the turret behaviour properly... at the moment I create a turret, then if the turret does not have a target, run "Add object to target" with the object in question a sprite in my game called "helicopter".

Then I have an action that's triggered by the "on shoot" event on my turret, which spawns a bullet and sets the angle towards "helicopter".

I hope that all made sense.

Anyway, the turret rotates and fires as it should when helicopters pass in range, however, it seems it always shoots at the earliest helicopter. So a helicopter can fly in range, fly out of range, another helicopter will fly into range, and the turret will rotate to face the second helicopter, but the bullet goes towards the first helicopter.

I assume this is because the helicopter is not selected in the "on shoot" event, so it just uses the first one, but how do I fix this?

'Add object to target' simply adds an object type to look for, so you only need to call it once on Start of Layout. 'Spawn object' will set the angle of the spawned object to the angle of the parent object, which is exactly what you want - you don't need to set the bullet's angle manually. 'On shoot' doesn't pick any helicopters so Construct doesn't know which helicopter you want to use. Delete the set angle action and it should all work fine.

Thanks for your quick response, the problem is I was hoping to make the bullets chase the target, that's why I needed to find what the turret's aiming at in the shoot event, rather than just the angle.

EDIT - actually, I suppose I could store the UID in a variable in the target acquired event, then find it again in the shoot event, is that the easiest way?

EDIT 2 - actually, I think I have the same problem in that event too... am I best off doing it manually rather than using the turret behaviour?

So now you want Bullet A to change course and chase Helicopter 2? Is that correct?[/quote:5ormrreq]

No, sorry, I want the turret to fire at the helicopter it's currently aiming at, from the "on shoot" event. The trouble is, the specific helicopter can't be determined within the "on shoot" event, only the angle, so I can't tell the bullet which helicopter it should be chasing.

I think you've got it right up to the end, deadeye. But if I'm reading it right he wants the bullet to keep chasing the first helicopter, even when the turret isn't targetting it, but for new bullets fired not to chase it.
Because he's picking the first helicopter for the homing bullets and all bullets are globally homing on that target he can't have bullets chasing different targets.

[quote="Drew Carey":30ohvm9g]I think you've got it right up to the end, deadeye. But if I'm reading it right he wants the bullet to keep chasing the first helicopter, even when the turret isn't targetting it, but for new bullets fired not to chase it.Because he's picking the first helicopter for the homing bullets and all bullets are globally homing on that target he can't have bullets chasing different targets.[/quote:30ohvm9g]

Yes, that's right.

If the event was "on shoot at (object)", so in my example "on shoot at helicopter", then I could make the bullet follow that helicopter, or apply actions directly to the targeted helicopter, making the turret behaviour a lot more flexible.

Well, you're right, there's no easy way to access the targeted object from the turret movement. To remedy this I've added a 'Get Target UID' expression to the turret movement for the next build. You'll be able to do something like this:

[quote="Ashley":1digixzg]Well, you're right, there's no easy way to access the targeted object from the turret movement. To remedy this I've added a 'Get Target UID' expression to the turret movement for the next build. You'll be able to do something like this: