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.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…
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…
Translate(transform.position);
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()
{
playerbox.transform.Translate(target.transform.position);
}
Anyway. hope that helps some bud.
This should solve your issue, but let us know back here if not.
Take care Gruffy