问题描述
尝试调试此简单代码,这是我有史以来的第一个编码。只有错误说我错过了一个{
和一个}
,但是我想把它们放在哪里
using System.Collections;
using UnityEngine;
public class PlayerMovement : MonoBehavIoUr
public Rigidbody rb;
// Update is called once per frame
void Update()
{
//Positive X = Left,Negative X = Right,Positive Z = Backwards,Negative Z = Forwards
if (Input.GetKey("w")) ;
{
rb.AddForce(0,10);
}
}
解决方法
您的班级也只需要{
和}
。
public class PlayerMovement : MonoBehaviour
{
//Stuff for your class here
}
请尝试注意编译错误中的行号,以找出错误的位置,以便将来进行调试,这将使查找此类错误更加容易。
此外,您不应该在;
条件之后加上if
。它将阻止内部代码被执行。
针对您的班级。 结束不应该放;如果之后