围绕统一旋转2d

问题描述

我正在尝试将一个对象绕另一个对象旋转。 这是我正在使用的脚本:

bytes

还有一个脚本可以围绕另一个对象旋转对象:

string

public void LeftToRight() { levelInvarte.transform.RotateAround(character.transform.position,Vector3.back,90);

public GameObject objectToRotate;

private bool rotating;

private IEnumerator Rotate(Vector3 angles,float duration)
{
    rotating = true;
    Quaternion startRotation = objectToRotate.transform.rotation;
    Quaternion endRotation = Quaternion.Euler(angles) * startRotation;
    for (float t = 0; t < duration; t += Time.deltaTime)
    {
        objectToRotate.transform.rotation = Quaternion.Lerp(startRotation,endRotation,t / duration);
        yield return null;
    }
    objectToRotate.transform.rotation = endRotation;
    rotating = false;
}

public void StartRotation()
{
    if (!rotating)
        StartCoroutine(Rotate(new Vector3(0,-90),0.5f));
}

对于第一个代码,如第二个代码那样旋转(围绕另一个对象,在第一个代码中,它只是旋转对象而不是围绕某个对象),我应该编辑什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)