Local and world position changing

Hey guys, so I have this object which I try to move. I want to do this by setting one of the childobjects to a new position. However, when I do that local and world position change for some reason. Im running the following code
public void SetStartPosition(Transform transform){
Transform shipPositionPoint = start.transform.Find("ShipPosition");
Debug.Log("shipPositionPoint name: " + shipPositionPoint.name);
Debug.Log("transform name: " + transform.name);
Debug.Log("transform parent name: " + transform.parent.name);
Debug.Log("Local Position: " + shipPositionPoint.transform.localPosition);
Debug.Log("Global Position: " + shipPositionPoint.transform.position);
Debug.Log("--------------------------------------");
shipPositionPoint.transform.position = transform.position;
Debug.Log("Local Position: " + shipPositionPoint.transform.localPosition);
Debug.Log("Global Position: " + shipPositionPoint.transform.position);
}
public void SetStartPosition(Transform transform){
Transform shipPositionPoint = start.transform.Find("ShipPosition");
Debug.Log("shipPositionPoint name: " + shipPositionPoint.name);
Debug.Log("transform name: " + transform.name);
Debug.Log("transform parent name: " + transform.parent.name);
Debug.Log("Local Position: " + shipPositionPoint.transform.localPosition);
Debug.Log("Global Position: " + shipPositionPoint.transform.position);
Debug.Log("--------------------------------------");
shipPositionPoint.transform.position = transform.position;
Debug.Log("Local Position: " + shipPositionPoint.transform.localPosition);
Debug.Log("Global Position: " + shipPositionPoint.transform.position);
}
No description
3 Replies
TheOneAndOnly
TheOneAndOnly6mo ago
The child object moves to the new position best the rest does simple not
Starzy
Starzy6mo ago
Local position is the position relative to its parent, it's what the unity editor shows when you click on an object World position is position within the world, as if it had no parent object You'll probably want to learn the difference, and how to convert between them, i.e the transform and inverse transform methods/matrices
TheOneAndOnly
TheOneAndOnly6mo ago
I though that I read that if you change the position of the child object that the parent object moves along Is that not correct than?