hello, im still a newbie to scripting plus don’t really understand it, so i want to know if anyone can help me do a homing script. i have created all the models for the missile and launcher and all i need is some help with scripting it… any suggestion is helpful to point me in the right direction…Thanks
Use transform.LookAt and Vector3.MoveTowards.
See also:
When an answer satisfies your problem please mark it as answered (by clicking/tapping the check mark next to the answer).
Also please don’t just ask user to write a script for you if you don’t know the language. If you don’t know the general way to get what you wnat is another story, but please don’t give up and ask if you just don’t know the language. Just a helpful idea to try and get you to try and learn it for yourself, as you’ll learn it quicker if you do, instead of being handed code you have no idea how it works.
The general approach to any scripting problem is to know the steps and info you need to solve it.
In this case you need the target position and your projectile position.
Then you need to tell it to rotate towards its target. So you want to get the transform components of each (these store rotations and positions of each gameObject). Then you want to slowly rotate towards your target. Then when you get close enough to the actual target rotation (so your almost facing the target) you set the projectile rotation to the one you want.
I would advise looking up Quaternions on unity documentation and utilizing the unity documentation to get a general feel of methods and such.
Also, I would suggest sticking to c# for your script language. It’s not too hard to learn, and is very widely known, even in non-unity applications. The unity language “javascript” is not the web form at all, so it is confusing in this sense and not as widely known.
Hope this helps.