どうもどうも。
とうとう今日からUnityさわってみてます。
とりあえず3Dは難しそうなので2Dのチュートリアルしてます。
下記のチュートリアルでお世話になってます。
ありがたや。。
Unity2D】Unityで2Dミニゲームを作るチュートリアル
ところが途中でたこ焼きくんをランダムで動かそうとするときにエラーが。。。
ナンデナン。カイテアルトオリニヤッタノニ。。
all compiler errors have to be fixed before you can enter playmode
ん?何言ってんのこれ。
得意の翻訳サイトペタペタで解読してみると
「あなたがplaymodeを入力できる前に、すべてのコンパイラエラーは固定される必要がある」
むむむ。。まぁ要はコンパイルエラーあるから直せよってことかな?
どれどれ。どこがマズってんのよ。
UnityさんのConsoleに何かでてるじゃない。
・Assets/Scripts/Token.cs(211,19): error CS0619: `UnityEngine.Component.rigidbody2D’ is obsolete: `Property rigidbody2D has been deprecated. Use GetComponent
・Assets/Scripts/Token.cs(211,31): error CS1061: Type `UnityEngine.Component’ does not contain a definition for `velocity’ and no extension method `velocity’ of type `UnityEngine.Component’ could be found (are you missing a using directive or an assembly reference?)
・Assets/Scripts/Token.cs(219,19): error CS0619: `UnityEngine.Component.rigidbody2D’ is obsolete: `Property rigidbody2D has been deprecated. Use GetComponent
・Assets/Scripts/Token.cs(219,31): error CS1061: Type `UnityEngine.Component’ does not contain a definition for `velocity’ and no extension method `velocity’ of type `UnityEngine.Component’ could be found (are you missing a using directive or an assembly reference?)
・・・。。
あ、エディタみたら何かでてた。
変数みつかんないってことかな。
ってことで
「Vector2 v = rigidbody2D.velocity;」
これを
「Vector2 v = _rigidbody2D.velocity;」
こうしました!
よし、とりあえず動いたので先に進めるとします!!