前提・実現したいこと
unityのチュートリアル「はじめてのunity」での、スクリプトを作る章(https://unity3d.com/jp/learn/tutorials/projects/hajiuni/moving-the-player?playlist=45986)でエラーメッセージが発生しました。
発生している問題・エラーメッセージ
本当に初歩的な質問ですみません。ホームページにあるようにvisual studioを使いコードを書き込んだところ、All compiler errors have to be fixed before you can enter playmodeと表示され、下記のエラーメッセージが出ました。
The type or namespace name `MonoBehaviour' could not be found. Are you missing `UnityEngine' using directive?
該当のソースコード
using System.Collections; using System.Collections.Generic; public class PlayerController : MonoBehaviour { public float speed = 10; void FixedUpdate() { float x = Input.GetAxis("Horizontal"); float z = Input.GetAxis("Vertical"); Rigidbody rigidbody = GetComponent(); rigidbody.AddForce(x * speed, 0, z * speed); } }
試したこと
ホームページのものをコピぺしても変わりませんでした。コンポーネントを一度消してみると動作したのでこれが原因だと思われます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。