2D Rigidboy, have child keep upright but allow parent to rotate

The title says it all, trying to have my parent rotate but an object attached to it stay upright via the keep upright variable on 2d rigidbody, tried using hinge joints to no avail, is this possible?

Hi,

first of all, you have 2 choices to set rotation:

  1. transform.localRotation - this is relative to parent, so zero rotation means same as parent
  2. transform.rotation - this is world rotation, so the angle you set is angle it will face regardless of parents

if child rigid body it is not necessary, you could try to create a script and attach it to your child

private Quaternion rotation;

private void Awake() {
    rotation = transform.rotation;
}

private void LateUpdate() {
    transform.rotation = rotation;
}

This way you are setting global rotation of child to one that was set right at the beginning, so object keeps facing that direction what you set in the editor.

If you look here
https://docs.unity3d.com/uploads/Main/monobehaviour_flowchart.svg
you see that in late update, you can set rotation after everything was applied so it is not changed by physics before render.