Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: mike90136 on October 11, 2016, 10:02:53 PM

Title: Use Find Closest to trigger event
Post by: mike90136 on October 11, 2016, 10:02:53 PM
Hello everyone , this is my scene

(https://drive.google.com/uc?export=view&id=0B9WbX9m5OeebbXQ1dFNGbVJBRnM)

I have eight spawn points around my ship and the missile will come randomly from those spawn points.

(https://drive.google.com/uc?export=view&id=0B9WbX9m5OeebOVBLYWh5cnh6SGc)

I have eight sensors around my ship and twelve lunchers on my ship , every time a missile spawn from any spawn point , I use Find Closest to find which sensor is the closest one to the missile.

(https://drive.google.com/uc?export=view&id=0B9WbX9m5OeebX2xtTGg0NUhxc0U)

my problem is when I find out which sensor is the closest one to the missile and store it to the GameObject variable(DecoySensor).How to make lunchers fire depend on the GameObject variable(DecoySensor)??

For example when sensor 8 is the closest one to the missile so I want luncher 1 3 5 to be choose to fire.
Title: Re: Use Find Closest to trigger event
Post by: djaydino on October 12, 2016, 08:24:37 AM
Hi,
Maybe you can place your "sensor" objects into an array then after you found the closest object you can use "array contains" and store the index nr.
with that number you can use a "int switch"

or maybe you can have multiple arrays, one containing your "sensor" objects and  3 other containing the  launcher's

So when you got the index number from your sensor you can use that to get the launcher's

Let say sensor 8 is on index 7 , on the 3 other array you should have launcher 1, 3 and 5 on index number 7
Title: Re: Use Find Closest to trigger event
Post by: mike90136 on October 12, 2016, 10:23:50 PM
THX~djaydino

This is my result and it work just like what I want~!! ;D

(https://drive.google.com/uc?export=view&id=0B9WbX9m5OeebWTVUTkh4QVBWU0E)
Title: Re: Use Find Closest to trigger event
Post by: djaydino on October 13, 2016, 05:15:03 AM
Hi,
I am happy you got it to work :)