当前位置:网站首页>Rigidbody2d rotate around a fixed point rotate

Rigidbody2d rotate around a fixed point rotate

2022-06-09 04:05:00 KillJUMP

  1. public void rotateRigidBodyAroundPointBy(Rigidbody rb, Vector3 origin, Vector3 axis, float angle)
    {
        Quaternion q = Quaternion.AngleAxis(angle, axis);
        rb.MovePosition(q * (rb.transform.position - origin) + origin);
        rb.MoveRotation(rb.transform.rotation * q);
    }

    Swining a rigidbody around a point - Unity Answershttps://answers.unity.com/questions/514863/swining-a-rigidbody-around-a-point.html

hold  Rigidbody rb Change it to Rigidbody2D rb That is to say

Personal test Very easy to use !

There are several other ways :

1. Use animation hinge

2. Create parent object rotate parent object and delete parent object

原网站

版权声明
本文为[KillJUMP]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206090358345355.html