オブジェクトを画面をクリック(タップ)で上に飛ばすコードを書いたところ、次のエラーが**2つ(全く同じエラー)**出てきました。
エラーの直し方がわかる方、ご回答お願いします。
↓コード
C#
1using UnityEngine; 2using System.Collections; 3using UnityEngine.UI; 4using UnityEngine.SceneManagement; 5 6public class PlayerScript : MonoBehaviour { 7 public static int score = 0; 8 9 void Update () { 10 this.transform.Rotate (new Vector3 (0, 0, -1 * Time.deltaTime)); 11 12 if (Input.GetMouseButtonDown (0)) { 13 GetComponent<Rigidbody> ().velocity = new Vector3 (0,6,0); 14 GetComponent<AudioSource> ().Play (); 15 } 16 } 17}
↓エラー内容
MissingComponentException: There is no 'Rigidbody' attached to the "Player" game object, but a script is trying to access it. You probably need to add a Rigidbody to the game object "Player". Or your script needs to check if the component is attached before using it. UnityEngine.Rigidbody.set_velocity (Vector3 value) (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/modules/Physics/DynamicsBindings.gen.cs:1297) PlayerScript.Update () (at Assets/Scripts/PlayerScript.cs:13)
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。