Use Function for Turret has problem!

Get help using Construct 2

Post » Wed May 18, 2016 7:40 am

Hi,

i have some tower for my game and i use function like:

On "SpawnBullet" = > > > > tower ==> spawn bullet on layer 0

and i call it for tower,
but when one tower has target, the other tower shoot too!
why?
B
10
S
3
Posts: 180
Reputation: 1,212

Post » Wed May 18, 2016 8:10 am

Because the tower is probaly 'unreferenced'.

https://www.scirra.com/manual/75/how-events-work

Functions start picking from scratch. Meaning, the tower is not picked. When no tower is picked, the actions run on all towers.

2 solutions.

1/ If the tower has a turret behaviour, then use the 'on shoot' trigger. It is meant for this.

2/ More generaly. If you picked an object and want to call a function with actions that work for that object. Then add the expression object.UID as a parameter to the function call. And in the 'on function' you use the condition 'pick by UID' with UID= object.function.param(n).
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed May 18, 2016 8:44 am

@99Instances2Go

thank you so much. i try for that.
B
10
S
3
Posts: 180
Reputation: 1,212


Return to How do I....?

Who is online

Users browsing this forum: Fradno, Shenkai the ssj and 27 guests