Pra*_*shi 2 c# unity-game-engine
我刚开始在unity3d工作.
我有这堂课
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
private Rigidbody rb;
void start()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rb.AddForce(movement);
}
}
Run Code Online (Sandbox Code Playgroud)
它显示一个错误:
NullReferenceException:Object Reference未设置为对象的实例.
line:11 {rb.AddForce(movement)}
如果有人知道问题是什么以及如何解决,请分享.
归档时间: |
|
查看次数: |
145 次 |
最近记录: |