playMaker

Author Topic: Use Find Closest to trigger event  (Read 1751 times)

mike90136

  • Playmaker Newbie
  • *
  • Posts: 2
Use Find Closest to trigger event
« on: October 11, 2016, 10:02:53 PM »
Hello everyone , this is my scene



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



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.



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.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Use Find Closest to trigger event
« Reply #1 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

mike90136

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Use Find Closest to trigger event
« Reply #2 on: October 12, 2016, 10:23:50 PM »
THX~djaydino

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



djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Use Find Closest to trigger event
« Reply #3 on: October 13, 2016, 05:15:03 AM »
Hi,
I am happy you got it to work :)