- Home /
What is difference between local and global coord Vector3.
I have point on the map name is FocalPoint in the center map 0.0.0, and to him have been linked camera, for scroll around circle like a planet. And my question is Why if i am used rigidBody.AddForce(focalPoint.transform.forward)
i change direction my player localy relative to this point and this work how is need, player moving forward or back where i look. but if i was trying do this playerRb.AddForce(new Vector3(0,0, focalPoint.transform.localPosition.z)
my player didnt move, but if here plus 1 player have been mooving globaly Z not local how its work? Because transform.forward = new Vector3(x=0, y=0, z = 1)
;
Answer by highpockets · Feb 10, 2021 at 09:14 PM
You say that focalPoint.transform.localPosition is at the world origin (0,0,0). Does the focalPoint move?? and is it a root object in the hierarchy? because if it stays at (0,0,0) and it is a root object (it has no parent), then its localPosition.z will be 0, so you won't see any force added. I think what you may be want to accomplish is to get the direction from the player to the focalPoint (`(focalPoint.transform.position - playerRb.transform.position).normalized`), that will be the direction you have to move in to get the player back to the focalPoint.
Anyhow, for your question about what is the difference between world and local coords. Well everything will start at the world origin. The localPosition of any root object (object with no parent) will be the same as the object's world position because the world origin is like that object's parent. When that root object has a child, the child's localPosition is relative to the parent. So the local space origin for the parent object will be (0,0,0) in local coords, but it could be anywhere in the world space. So it could be at (100,10,120) in the world, but to all of its direct children it will still be at the local space origin of (0,0,0) )..
Your answer
Follow this Question
Related Questions
Need help for player rotation and camera rotation 0 Answers
First Person Controller wont look up or down 0 Answers
How to smooth my camera (Vector3.Lerp) 0 Answers
Camera move with mouse 0 Answers
How to make my player look in the direction of its movement? 3 Answers