position game object relative to another game object

Hello ,

Please how to know, position of a game object relative to another gameobject without using gameobject relationship, father son,

Thank you very much and good day.

Best regards .

With this i receive same value as with relationship:

public class NewBehaviourScript : MonoBehaviour
{
    public Transform FirstTransform;
    public Transform SecondTransform;

    private void Start()
    {
        Debug.Log("First Relative to Second = " + (FirstTransform.position - SecondTransform.position));
        Debug.Log("Second Relative to First = " + (SecondTransform.position - FirstTransform.position));
    }
}
1 Like

Read a bit on Vector math :slight_smile:

3 Likes

Thank you very much

I just forgot the solution :frowning: