Hi,
Can somebody help clarify how to add an offset to the Y Axis on an instantiated prefab?
I have:
Instantiate(myPrefab,myPrefab.transform.localPosition,Quaternion.identity);
I need to add about a positive 2 or 3 to the Y Axis.
Any help is really appreciated.
Thanks!
1 Like
Hi,
In your case I see two way to do it.
The first (and better for me) :
Instantiate(myPrefab, myPrefab.transform.localPosition + (myPrefab.transform.up * 2), Quaternion.identity);
The second :
Instantiate(myPrefab,new Vector3(myPrefab.transform.localPosition.x, myPrefab.transform.localPosition.y + 2, myPrefab.transform.localPosition.z),Quaternion.identity);
I hope this help.
Vector3 offset = new Vector3(0, 2, 0);
Instantiate(myPrefab, myPrefab.transform.localPosition + offset, Quaternion.identity);