Search Unity

Question Changing center of gravity of a gameObject

Discussion in '2D' started by ei-india, Mar 20, 2023.

  1. ei-india

    ei-india

    Joined:
    Dec 16, 2022
    Posts:
    1
    How do I change the center of gravity of a 2d gameObject(using a sprite renderer). Basically what I want to do is make the object rotate around a different pivot point when specified. Any help appreciated.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,742
    Some possibilities:

    You can change the pivot in the sprite editor.

    You can offset it with a hierarchy of GameObjects (offsetting the children)

    You could compute the offsets yourself and apply them.

    Since you said "center of gravity," if you are ACTUALLY talking about Rigidbody2D physics then there is a property to set the center of mass... go check the docs for Rigidbody2D.
     
    MelvMay likes this.