I'm trying to change the transform of an object I've just instantiated using the following:
public GameObject marker;
public float maxLength;
newVector = Vector2.ClampMagnitude(diffVector, maxLength);
Instantiate(marker, newVector, transform.rotation);
newVector = Vector2.ClampMagnitude(diffVector, maxLength);
marker.gameObject.transform.position = newVector;
Debug.Log("Marker position = " + marker.gameObject.transform.position);
The diffVector is the difference between two objects that I want to track. There is other code around each block above but these are the pertinent parts.
I use the Debug.log to see that the marker.gameObject.position.transform is changing correctly, but the actual game object marker(clone) isn't.
My guess is because its a clone but I don't know how to reference them in the script.
Any help would be appreciated.
↧