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

Unity 2D:角色行至两平台间时平台无故逆时针旋转求助

求助:Unity 2D游戏中角色移动至平台中间时平台意外逆时针旋转

各位大佬晚上好!我是刚入坑Unity的新手,今晚折腾我的第一个2D小游戏的时候碰到了个莫名其妙的问题:我的玩家角色(一个GameObject)能正常从左向右移动,但当它走到两个平台的中间位置时,平台居然会开始逆时针旋转,完全不是我预期的效果!

先跟大家说下相关对象的组件配置:

  • 玩家对象:挂载了RigidBody2D和Box Collider 2D组件
  • 平台对象:只挂载了Box Collider 2D组件

这是我写的玩家控制代码:

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

public class PlayerControls : MonoBehaviour {
    public Rigidbody2D rb;

    // Start is called before the first frame update
    void Start() {
        rb = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update() {
        rb.velocity = new Vector2(1, rb.velocity.y);
        if(Input.GetMouseButtonDown(0)) {
            rb.velocity = new Vector2(rb.velocity.x, 10);
        }
    }
}

我还截了游戏运行时的截图,能看到平台旋转的状态:
平台意外旋转的游戏截图

有没有大佬遇到过类似的问题?或者能帮我分析下可能的原因吗?万分感谢!

内容的提问来源于stack exchange,提问作者Adam Laurie

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.11 08:07:47