Direction vectors

I must be retarded or something. I want a vector from one object to another. When object a is on the origin it works great. But the farther it gets from the origin the more inaccurate the direction vector gets. What am I doing wrong?

Here’s my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class vectorshit : MonoBehaviour {

    public Transform other;
    public Vector3 direction;

    private void OnDrawGizmos()
    {
        direction = other.position - transform.position;
        //direction.Normalize();
        Gizmos.color = Color.red;
        Gizmos.DrawLine(transform.position, direction);
    }
}

Screens, first is offset, second is at origin


Good day.

To know the vector from objectA to objectB, you just need what you did:

direction = other.position - transform.position;

If this vector is not what its suposed to be, is because some of the positions you are using is not correct. Maybe some object position is not the 0,0,0 of that object, maybe the mesh is not at the center of the object, so you dont “see the line going at right position”, but it is going to the position of the object, so… check if both meshes are really in the center of the GameObject position.

If is not at the center and the transform scale is not 1,1,1 it will increasse/decrease the differene.

Bye!