How do i use Turret behaviors?

Get help using Construct 2

Post » Sun Apr 07, 2013 8:20 pm

Hi there,

I would like to use turret behavior, but it seem i canno't figure it out.Can anyone please assist me?The cannon is not rotating and not firing.

Here is the event sheet:
B
5
Posts: 25
Reputation: 750

Post » Sun Apr 07, 2013 8:50 pm

If that's the totality of your turret's events, then you need to add targets for the turrets to acquire. Turrets need to know what to shoot before they'll do anything useful.

Have a read through page four of my tutorial for an overview of the behaviour in action, and don't neglect the manual entry.
B
56
S
15
G
10
Posts: 910
Reputation: 11,952

Post » Mon Apr 08, 2013 3:47 pm

[QUOTE=GeometriX] If that's the totality of your turret's events, then you need to add targets for the turrets to acquire. Turrets need to know what to shoot before they'll do anything useful.

Have a read through page four of my tutorial for an overview of the behaviour in action, and don't neglect the manual entry.[/QUOTE]
But i have added a target,or have i plan it wrong?
B
5
Posts: 25
Reputation: 750

Post » Mon Apr 08, 2013 4:19 pm

Got it working!Great tutorial GeometriX
B
5
Posts: 25
Reputation: 750

Post » Mon Apr 08, 2013 5:07 pm

For the record, your mistake was to use 'Add target' in the 'Has target' event. That will never run because you must add a target before a turret can have a target. Add your targets on 'start of layout'.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Mon Apr 08, 2013 8:14 pm

You can also do something like add a trigger that when the player/enemy/whoever gets within a certain distance of the turret that it aquires them as the target and then use "Add target".
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,418

Post » Wed Apr 10, 2013 8:38 pm

Got it working, i have changed the code and its ok now.If i will need anything else i will post here.Thanks both for a response helped alot!
B
5
Posts: 25
Reputation: 750

Post » Tue Nov 12, 2013 4:08 pm

From what I've seen, both the turret and the target must exist in the layout before adding a target will work.

In my case, the turret is part of many actions that can be taken during the game, and the turret only exists as part of the project, not the layout.

So when I add a target at the start it doesn't work, since neither the turret or the target exist.

If I put the add in the "on created" for my enemy (the target), it only works if the turret exists before the enemy is created.

So, I tried a family that includes my turret and my enemy, and a condition for the family "on created" to add my target if either the turret or the target is created. If I had the enemy on screen first, then created a turret, this didn't work. Only worked if I had the turret first, then created the enemy.

So then I put them in an OR block instead, with an "on created" for the turret and enemy, and the same action of adding the target as when I had the family condition set up. This time it worked, no matter what order they were in.

Not sure why it didn't work with the family condition set up, maybe I had it wrong. No big, the OR block works fine for my setup.
B
16
S
1
G
3
Posts: 43
Reputation: 2,597

Post » Sun Nov 27, 2016 8:00 am

To me still dont working is only rotating but dont do anything
B
4
Posts: 3
Reputation: 210


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, BipolarMike, totoe and 20 guests