Search Unity

Gameobject pivot vs center

Discussion in 'Physics' started by MrJohny, Jul 4, 2015.

  1. MrJohny

    MrJohny

    Joined:
    Feb 19, 2015
    Posts:
    73
    Hi
    Can anyone explain why objects are moved by a pivot not center? I have choose center but still move the object using the pivot. Iam using for move this code:
    Code (CSharp):
    1. objekt.GetComponent<Rigidbody>().MovePosition(hit.point)
     
  2. PGJ

    PGJ

    Joined:
    Jan 21, 2014
    Posts:
    899
    The button is effective for the tools in the editor and it doesn't effect how an object is transformed during run time.
     
    JamesLeeNZ likes this.
  3. MrJohny

    MrJohny

    Joined:
    Feb 19, 2015
    Posts:
    73
    And know someone how to move with "center" during run time?
     
    siraponte likes this.
  4. PGJ

    PGJ

    Joined:
    Jan 21, 2014
    Posts:
    899
    You can find the center of your object with: transform.renderer.bounds.center.You should be able to calculate the offset from your pivot and adjust your movement using that...
     
  5. MrJohny

    MrJohny

    Joined:
    Feb 19, 2015
    Posts:
    73
    Ok, so i solved problem as follows... i changed pivot point like in this video. If someone did not know in the future
    '
    '
     
  6. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    you can make the item you want a child of a new gameobject.