UnityEngine.Component'不包含'velocity'的定义

时间:2019-01-23 16:42:59

标签: c# unity3d

我正在追踪Unity太空射击游戏第1-6章中的this tutorial

In [38]: df_1.merge(df_2.rename(columns={'Team':'HomeTeam', 'Game N.':'index','Value':'Value_Home'}))
Out[38]: 
   index       Date     HomeTeam   AwayTeam  Value_Home
0      0  8/14/1993      Arsenal   Coventry          -1
1      1  8/14/1993  Aston Villa        QPR          -2
2      2  8/14/1993      Chelsea  Blackburn           0

我编写的代码完全相同,但是出现以下错误:

  

Unity错误:UnityEngine.Component'不包含“力度”的定义

1 个答案:

答案 0 :(得分:1)

您必须使用rigidbody而不是Rigidbody。当前,您正在访问类Rigidbody而不是类成员rigidbody

using UnityEngine;
using System.Collections;

public class PlayerControl : MonoBehaviour 
{
    // Use this for initialization
    void FixedUpdate ()
    {
        float moveHorizontal = Input.GetAxis ("Horizontal");
        float moveVertical = Input.GetAxis ("Vertical");

        Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
        rigidbody.velocity = movement;
    }
}