我无法在地面上移动玩家。但是,如果我尝试在空中移动它,它的确会移动。我不知道怎么了这是代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playerJump : MonoBehaviour
{
public Rigidbody rb;
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.UpArrow) && rb.transform.position.y==1)
{
rb.AddForce(0, 7, 0, ForceMode.Impulse);
}
if (Input.GetKey(KeyCode.RightArrow))
{
rb.AddForce(4*Time.deltaTime, 0, 0, ForceMode.Impulse);
}
if (Input.GetKey(KeyCode.LeftArrow) )
{
rb.AddForce(-4 * Time.deltaTime, 0, 0, ForceMode.Impulse);
}
if (Input.GetKeyDown(KeyCode.DownArrow) )
{
rb.AddForce(0, -7, 0, ForceMode.Impulse);
}
}
}
没有错误消息。