为什么我的刚体Z方向不移动?团结



所以我使用的代码是:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
Rigidbody rb;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown("space"))
{
rb.velocity = new Vector3(0, 5, 0);
}
if (Input.GetKey("up"))
{
Debug.Log("pressed");
rb.velocity = new Vector3(0, 0, 5);
}
}
}

相当简单,当我按下空格时,玩家会跳起来。当我按下向上键时,我会在控制台上看到一个日志,但播放器根本不动。我被难住了,已经调试了一段时间了。

有人知道为什么吗?

顺便遵循本教程:https://youtu.be/54qz4SyQWZM?list=PLrnPJCHvNZuB5ATsJZLKX3AW4V9XaIV9b&t=2265

编辑:这是我的对象设置https://gyazo.com/3ec3a192b401f6335547beb84e07d8fb

修复了它!不得不禁用";应用根部运动";在我的播放器对象动画师上。

https://gyazo.com/401c5f12b5bb4cf5aab1f0d94990353b

最新更新