Skip to content

Instantly share code, notes, and snippets.

@kurtdekker
Created January 25, 2022 22:50
Show Gist options
  • Save kurtdekker/d32780c3b1846b21e7b89dcc833a63f6 to your computer and use it in GitHub Desktop.
Save kurtdekker/d32780c3b1846b21e7b89dcc833a63f6 to your computer and use it in GitHub Desktop.
Sets center of mass on a Rigidbody2D
using UnityEngine;
// @kurtdekker
// to use, place this on the GameObject where your Rigidbody2D is located
public class SetRB2DCenterOfMass : MonoBehaviour
{
public Vector3 DesiredCenterOfMass;
void Start ()
{
GetComponent<Rigidbody2D>().centerOfMass = DesiredCenterOfMass;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment