Match position of two object without making one a child of the other


I was wondering how I would go about this. Currently I tried this, but this just gives a boatload of errors.

playerbox.transform.Translate = new Vector3(transform.Translate.x, transform.Translate.y, transform.Translate.z);

This script is on object A, and playerbox is the object I want to match position and movement on (but not rotation!).

Any tips or hints in the right direction would be greatly appreciated!


Thanks for the great advice! I tried some of it out, and I’m not sure if I’m doing it right, but


moves the playerbox in the correct direction, but at a different speed compared to the original object. I however intend to have the playerbox and the original object to stay at the same speed and location relative to each other, much like as if one was a child of the other.

playerbox.transform.position = transform.position;

Does what I want, but I do not want the playerbox object at the exact same location as the original object.

Any suggestions how I could do this?


I found a workaround which was better then my original design :slight_smile: Thanks for the help guys, you really pointed me in the right direction!

Translate is a function, do the same with transform.position

Okay here…

playerbox.transform.Translate = new Vector3(transform.Translate.x, transform.Translate.y, transform.Translate.z);

you are trying to match the Translate method a little wooozy like.
So, if you wanted one transform object to = another you might try writing it like so…

playerbox.transform.Translate(transform.position * time.deltaTime);

What you were trying to say with your code was a good attempt, but Unity needs it in the fashionabove.

All i did was take your code

new Vector3(transform.Translate.x, transform.Translate.y, transform.Translate.z);

and instead of assigning it with “=”, it was assigned using the correct syntax for the method structure, which was…


with the parenthesis(curly brackets) being the important addition and only the need to reference your other transform`s position as the method requires, like you already sussed out there, a Vector3 coordinate.

The only real issue I would have with your code is that your are effectively making your playerBox tranform = the transform of the code that this script is attached to…
For ease of use and understanding, perhaps make two public GameObject slots in your script and place both transforms you want to move in there and use there respective cache variable names as prefixes to your transform Translation object and the object you are translating to…
something like…

public Transform playerBox; //accesible through inspector
public Transform target;

void Update()

Anyway. hope that helps some bud.
This should solve your issue, but let us know back here if not.
Take care Gruffy

You could directly set the position of your GameObject, like so:

playerbox.transform.position = transform.position;

Just use:

followingObject.transform.position = leadingObject.transform.position;

If you want to use a more smoother, or some kind of delay follow, you can use Vector.Lerp or Vector3.Slerp:

public float smoothing = 4;

followingObject.transform.position = Vector3.Lerp(followingObject.transform.position, leadingObject.transform.position, Time.deltaTime * smoothing);