物体围绕着target y轴向旋转,target y轴向多少度,该物体多少度

it2022-05-05  129

物体围绕着target y轴向旋转,target y轴向多少度,该物体多少度

using UnityEngine; using System.Collections;

public class Test : MonoBehaviour {     public Transform target;     private float lastRotY;     private void Update()     {         if (lastRotY < target.eulerAngles.y)         {             transform.RotateAround(target.position, Vector3.up, Quaternion.Angle(Quaternion.Euler(0, target.eulerAngles.y,0), transform.rotation));         }         else         {             transform.RotateAround(target.position, Vector3.up, -Quaternion.Angle(Quaternion.Euler(0, target.eulerAngles.y, 0), transform.rotation));         }         lastRotY = target.eulerAngles.y;     } }


最新回复(0)