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

Unity中Cube与Plane碰撞后漂浮旋转问题求助

解决方案
  • 改用Rigidbody的MovePosition控制移动:直接修改Transform.position会绕过物理引擎的碰撞处理逻辑,导致刚体和静态Plane交互时出现异常。建议在FixedUpdate(物理帧更新)里使用Rigidbody的方法来移动:

    public float moveSpeed = 2f;
    private Rigidbody rb;
    
    void Start() {
        rb = GetComponent<Rigidbody>();
    }
    
    void FixedUpdate() {
        // 示例:按上下键控制Y轴移动
        float input = Input.GetAxis("Vertical");
        Vector3 targetPos = rb.position + new Vector3(0, input * moveSpeed * Time.fixedDeltaTime, 0);
        rb.MovePosition(targetPos);
    }
    
  • 锁定刚体旋转:在Cube的Rigidbody组件中,勾选Freeze Rotation下的X、Y、Z三个轴,这样即使碰撞产生力矩,Cube也不会发生旋转。

  • 给Plane添加运动学Rigidbody:给Plane添加Rigidbody组件并勾选Kinematic,将其设为运动学静态物体,能让物理引擎更稳定地处理与动态刚体的碰撞,减少漂浮类异常。

内容的提问来源于stack exchange,提问作者Tub The Teletubbie

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.08 07:28:15