私はC#の新機能ですので、これが明らかであれば私を許してください。Unity Error:UnityEngine.Component 'に' velocity 'の定義が含まれていません
this tutorialの手順に従っており、手順6で問題が発生しました。それが与えるエラーはこれです:それが与える誤差はこれです:
using UnityEngine;
using System.Collections;
public class RobotController : MonoBehaviour {
//This will be our maximum speed as we will always be multiplying by 1
public float maxSpeed = 2f;
//a boolean value to represent whether we are facing left or not
bool facingLeft = true;
//a value to represent our Animator
Animator anim;
// Use this for initialization
void Start() {
//set anim to our animator
anim = GetComponent<Animator>();
}
// Update is called once per frame
void FixedUpdate() {
float move = Input.GetAxis ("Horizontal");//Gives us of one if we are moving via the arrow keys
//move our Players rigidbody
rigidbody2D.velocity = new Vector3 (move * maxSpeed, rigidbody2D.velocity.y);
//set our speed
anim.SetFloat ("Speed",Mathf.Abs (move));
//if we are moving left but not facing left flip, and vice versa
if (move < 0 && !facingLeft) {
Flip();
} else if (move > 0 && facingLeft) {
Flip();
}
}
//flip if needed
void Flip(){
facingLeft = !facingLeft;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
}
エラーがライン23上にある:
に使用rigidbody2D.velocity = new Vector3 (move * maxSpeed, rigidbody2D.velocity.y);
、正常に動作します'; 'と'にSystem.Collectionsを使用して。 – TrumpetDude
あなたの質問に既にあなたがいるので、私はそれらを目的から外しました。クラス内のすべてを新しいクラスに置き換えるだけです。 – Programmer