- Home /
find GameObject and move towards it, help please?
Hello,
I have an instance where balloons float in the 2d scene between -7, and 7 on the x axis and floats from -4 on the y axis to 8. I have an empty gameobject at vector2.zero as a spawner. I would like that whenever the balloons enter vector2(random.range (-5,5), random.range (-4, 4) ) in the scene, that the spawner identifies the balloon and spawns a ppin (gameobject) for each balloon in that range. The pin will then move towards the balloon and collide with it. Can anyone help me with getting this scripted? any help will be very much appreciated. Thanks in advance
On your pin object/tower/shooter thing, make a call to Phsyics2D.OverlapCircle. This will tell you if any balloons are inside the specified range. From there, you can get the position of that balloon using the Transform and instantiate a pin to face that direction, then apply a forward force.
How do you imagine a detecting zone for you your balloons that is size of Random.Range? It is going to be scaling every frame. $$anonymous$$aybe you meant a static zone of predefined size 10x8 centered?
Your answer
![](https://koobas.hobune.stream/wayback/20220613175930im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
instantiate problem help? 1 Answer
How would i use a 2D array for level generation 0 Answers
Multiple Fire Points 2 Answers
Object movement - undesired effects 1 Answer
Avoiding instantiating two things in same location? 1 Answer