My parent object components: Rigidbody2D and the script I shared below.

Children(Head, Body, Arm, Backpack...): There is only collider. There is no rigidbody2D. (I want the parent object to use the children's colliders, so I haven't add a rigidbody)

I want all my objects to rotate smoothly on their own axis. In the script below, it does not rotate on its own axis.

[SerializeField] public DynamicJoystick joystick;
public float speed;
Vector2 move;
public Rigidbody2D rb;

//Smoothly Turn
float _z;
float angle;
float turnSpeed = 15f;

void FixedUpdate()
    move.x = joystick.Horizontal;
    move.y = joystick.Vertical;
    float x = joystick.Horizontal;
    float y = joystick.Vertical;
    angle = Mathf.Atan2(y, x) * Mathf.Rad2Deg;

    if (angle != 0)
        _z = angle;

    Quaternion rotate = Quaternion.AngleAxis(_z, Vector3.forward);
    rb.transform.rotation = Quaternion.Slerp(rb.transform.rotation, rotate, turnSpeed * Time.fixedDeltaTime);
    rb.MovePosition(rb.position + move * speed * Time.fixedDeltaTime);

  • \$\begingroup\$ Can you show us 1) how your object with the rigidbody is set up in the scene view, with the transform gizmo in Local Pivot mode so we can see where the object's origin is, and 2) what rotation behaviour you're observing and what makes it "not on its own axis"? Also, bear in mind that the delta time correction in your Slerp is wrong. \$\endgroup\$
    – DMGregory
    Commented Sep 18, 2021 at 13:52
  • \$\begingroup\$ After I prepared my gameobjem with children, I made prefabs. my gameobject's origin is not unitiy's stage origin (when I reset the transform all objects move to the right of center). While rotating the parent gameobject, instead of rotating on its own axis, it pretends to rotate around a circle. \$\endgroup\$
    – gunza
    Commented Sep 18, 2021 at 15:32
  • \$\begingroup\$ Please edit your question to show this setup in a screenshot as requested. \$\endgroup\$
    – DMGregory
    Commented Sep 18, 2021 at 15:39

2 Answers 2


When I gave a gizmo to my parent object, I saw that the gizmo wasn't in the center of my parent object. So the character is turning, but instead of rotating on its own axis, it rotates around the gizmo. I simply moved all the children to the center of my parent object (right in the middle of the gizmo) and the problem was solved.


Have you tried Rigidbody2D.MoveRotation ?

Example (press any key to rotate the object to 10 degrees):

public class Rotate : MonoBehaviour
    private float _angleVelocity = 10f;

    private Rigidbody2D _rigidbody;
    private bool _rotate;

    private void Awake()
        _rigidbody = GetComponent<Rigidbody2D>();

    private void Update()
        if (Input.anyKey)
            _rotate = true;

    private void FixedUpdate()
        if (!_rotate)

        _rigidbody.MoveRotation(_rigidbody.rotation + _angleVelocity * Time.fixedDeltaTime);
        _rotate = false;

It is recommended to read the input data using the Update method since it is called every frame.

  • \$\begingroup\$ I tried this, but it didn't work. \$\endgroup\$
    – gunza
    Commented Sep 18, 2021 at 15:34
  • \$\begingroup\$ What exactly didn't work? The code works fine, I tested it before posting. Most likely you have a problem somewhere else and not in code. Can you create a new minimal project that reproduces your problem and share it on github or somewhere else? \$\endgroup\$
    – Serg
    Commented Sep 18, 2021 at 17:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .