- Home /
How to write a script to destroy enemy once player circles around
I made a spaceship that has a trail renderer which makes it seem like it dispenses a line. I want the enemy to be destroyed once the spaceship fully circles the enemy using the line. How would i go about scripting this. Any help would be appreciated. Thanks for your help.
Answer by huntsfromshadow · Mar 27, 2014 at 01:34 PM
You will need to keep track of the ship's position every update, and basically build a line from it's start position to it's end. Then you'll need to check if you've made a closed loop. I'm not sure how exactly to do that, but you probably could mathematically figure it out. In 2D it would be easier than in 3D. I would suggest getting some graph paper and working it out on paper first.
Good Luck.
Your answer
Follow this Question
Related Questions
How to destroy GameObject's script(s)? 3 Answers
Need help with AI script 1 Answer
Enemy Health Problems 1 Answer
how can i destroy a cube when i press a gui button??? 1 Answer
Easy collision script not working, don't understand. 2 Answers