You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vector3.Lerp()平滑效果异常,手部摇摆系统卡顿问题求助

Vector3.Lerp()平滑效果异常,手部摇摆系统卡顿问题求助

大家好,我正在开发一个手部摇摆系统,目前遇到了一个棘手的问题:当我使用Vector3.Lerp()来实现手部跟随目标的平滑移动时,效果非常糟糕,明显能感觉到卡顿和不流畅的抖动。

我已经试过两种插值方法——Vector3.Lerp()和Vector3.Slerp(),但两者的表现没有任何区别;同时我还把代码分别放到了Update()、FixedUpdate()甚至LateUpdate()中执行,情况也没有得到明显改善。

下面是我的代码细节:

精简版核心代码

Transform target;
float smooth;

void Update()
{
    transform.position = Vector3.Lerp(transform.position, target.transform.position, smooth * Time.deltaTime);
}

完整代码

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HandSway : MonoBehaviour
{
    public float smooth;
    public float swayMultiplier = 1f;
    public Vector3 handOffset;
    public Transform target;

    private void Update()
    {
        float x = Input.GetAxisRaw("Mouse X") * swayMultiplier;
        float y = Input.GetAxisRaw("Mouse Y") * swayMultiplier;

        Quaternion xRot = Quaternion.AngleAxis(-y, Vector3.right);
        Quaternion yRot = Quaternion.AngleAxis(x, Vector3.up);
        Quaternion rotation = xRot * yRot * target.rotation;

        transform.localRotation = Quaternion.Slerp(transform.localRotation, rotation, smooth * Time.deltaTime);
        transform.position = Vector3.Lerp(transform.position, target.transform.position, smooth * Time.deltaTime);
    }
}

编辑器设置情况

  • 脚本挂载在名为Hand的游戏对象上
  • Inspector面板中,target字段已绑定场景内的Hand Pos对象

有没有大佬能帮我看看问题出在哪,怎么才能让手部的跟随变得流畅自然呢?

备注:内容来源于stack exchange,提问作者Erfan_Games

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.23 07:48:11