Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

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:
    39,015
    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.