I am a beginner at Unity C# scripting I followed the Unity Stealth Project Tutorials for learning scripting. He has used the term relative position ( int context to transform.position and transform.rotation ) I didn’t understand it at all. So what is relative position in 3D vectors and when and why to use it? Please help!
If you can provide examples with explanation that will be great! Also explain in terms of rotation in unity.
Relative position is the position of an object related to another object. Commonly calculated by otherTransform.position - thisTransform.position. If you are working with a child relative to it’s parent this is equivalent to transform.localPosition.
Think of those action sniper movies where there is a sniper and a spotter. Absolute position would be the spotter giving latitude and longitude. While technically correct, this is difficult for the sniper to use. On the other hand relative position (eg “600 m away at your 3 O’Clock”) is actually pretty useful.
AI is a common use of relative position. Like our sniper, AI wants to know which how far each object is from it’s own position. It makes many calculations much simpler.
There are plenty of other uses for it too.
Edit: And this is vector math. Vector math always starts with a picture. Always. I’m on my phone, so I can’t draw my usual paint masterpiece. This was the best I could find on google.
Oh OK so its used to find the distance between u positions? Then why is it used in Lerp when we want certain object to go to the players position why do we do this :-