Unity平滑旋转Quaternion. Slerp对象旋转到固定角度 平滑移动 Vector3.MoveTowards 您所在的位置:网站首页 unity人物旋转角度小于1 Unity平滑旋转Quaternion. Slerp对象旋转到固定角度 平滑移动 Vector3.MoveTowards

Unity平滑旋转Quaternion. Slerp对象旋转到固定角度 平滑移动 Vector3.MoveTowards

2023-07-01 02:19| 来源: 网络整理| 查看: 265

代码如下:

using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// Unity 物体旋转到固定角度 /// public class Rotaion : MonoBehaviour { Quaternion targetPoint; public Transform targetTransform; // Start is called before the first frame update void Start() { //将目标角度转成四元素进行计算 targetPoint = Quaternion.Euler(0, 180, 0); } // Update is called once per frame void Update() { //yong slerp 进行插值平滑旋转 transform.rotation = Quaternion.Slerp(transform.rotation, targetPoint, 2 * Time.deltaTime); //平滑移动 targetTransform.position 目标位置 transform.position = Vector3.MoveTowards(transform.position, targetTransform.position, 2 * Time.deltaTime); //if (Quaternion.Angle(targetPoint,transform.rotation )


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有