I am just wondering how to accomplish this effect. I have a rigidbody and I have a target, the rigidbody is changing position from time to time. Now at a specific point I want to add a force to the rigidbody which is aiming at that specific target no matter where the rigidbody is located at the time.
Anyone has done that before or knows how to do that?
That will just make it go random speeds depending on the distances between them. What you want is the the normalised vector between them, which you can multiply back up to the speed you desire?
Using GameObject.Find is terrible for performance too. Wait until you get bigger scenes.
True I thought of the normalized vector as well but wasn’t bothered to write the code down lol.
How else would you find a gameObject?? Unless of course you have it defined in the code as a GameObject right?
hey thanks guys, I have setup a specific tracking system with smart objects, so the game object is always knowing where the desired target is. just required that portion, I will give it a go with the normalized vector, thanks.
hmm okay strange, I guess I have to play with the values a bit, but for some reason its always shooting into one direction (down mostly).
What I am trying to achieve is an effect like this shooting barrels here: http://www.youtube.com/watch?v=Asryeyig1_Q
the code is almost working but for some reason its not shooting the player up, even if the target is up.
Sorry 7 years later I found this thread useful. Really helped me get the answer in a super simple way. So thank you! Thought I’d help fill in the last missing piece for @ @sebako maybe this is what was missing?