using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CubeMove : MonoBehaviour
{
// public float speed;
private Vector3 targetPosition = new Vector3(5, 0, 0);
private Vector3 refSpeed;
private Rigidbody rb;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
Debug.Log("update");
//transform.position += new Vector3(0.01f,0,0);
//1、指定速度
//gameObject.transform.Translate(Vector3. * speed);
//2、Lerp 设定终点,然后根据距离终点百分比移动
//var percent = 1 /((transform.position - targetPosition).magnitude);
//gameObject.transform.position = Vector3.Lerp(transform.position, targetPosition, 0.001f);
//3、SmoothDamp 和Lerp类似,只是更丝滑
//gameObject.transform.position = Vector3.SmoothDamp(gameObject.transform.p
unity移动的7种方式
最新推荐文章于 2026-05-16 05:10:54 发布

6903

被折叠的 条评论
为什么被折叠?



