Unity3d 单位误差CS0120

Unity3d 单位误差CS0120,unity3d,Unity3d,我刚进入unity3d,我用的是一本指南。但每次尝试编译时,都会出现错误CS0120。请帮帮我,不要把它标成复制品 using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerControl : MonoBehaviour { public float speed; // Use this for initialization void Start ()

我刚进入unity3d,我用的是一本指南。但每次尝试编译时,都会出现错误CS0120。请帮帮我,不要把它标成复制品

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

public class PlayerControl : MonoBehaviour {

public float speed;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}

void FixedUpdate () {
    float moveHorizontal = Input.GetAxis("Horizontal");
    float moveVertical = Input.GetAxis("Vertical");
    Vector3 movement = new Vector3(moveHorizontal,0.0f,moveVertical);
    Rigidbody.AddForce(movement*speed*Time.deltaTime);


}
}

这一行就是问题所在

Rigidbody.AddForce(movement*speed*Time.deltaTime);
你得到的错误是

错误CS0120:访问非静态成员“UnityEngine.Rigidbody.AddForce(UnityEngine.Vector3)”需要对象引用

如果你想给一个刚体添加力,这个刚体与你的脚本连接到同一个游戏对象上,那么你需要抓取这个ridigbody实例并应用力,就像这样

this.GetComponent<Rigidbody>().AddForce(movement*speed*Time.deltaTime);
this.GetComponent().AddForce(移动*速度*时间.deltaTime);