Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Transform Position in Mesh Instantiated from Script

Discussion in 'Editor & General Support' started by BeyondMASC, Jul 10, 2019.

  1. BeyondMASC

    BeyondMASC

    Joined:
    Feb 11, 2019
    Posts:
    9
    How to set/match the transform origin with the origin of the mesh, when the mesh is instantiated from Script.

    If a gameobject is instantiated (i.e. GameObject gO = Instantiate(meshGenPrefab);) without a specify position, the origin of the transform (i.e. origin to move, rotate and scale) appears at 0,0,0 global position and the gameobject is rendered in the place assigned.

    If the gameobject is instantiated with the specific position assigned (i.e. GameObject gO = Instantiate(meshGenPrefab, startPos, Quaternion.identity), the gameobject is rendered with an offset of the position assigned (i.e. with a offset of startPos).