前提・実現したいこと
ジャンプ台を実装したいがエラーが出てしまって実装できない
発生している問題・エラーメッセージ
NullReferenceException:Object reference not set to an object jumpbord,OnTriggerEnter(UnityEngine.Collider col)(at Assets/Scriptjumpbord.cs:24)
該当のソースコード
C#
1using System.Collections;using System.Collections.Generic; 2using UnityEngine; 3 4public class jumpbord : MonoBehaviour { 5 6 public float Player_Jump; 7 public bool Jump; 8 int test = 1; 9 10 GameObject player; 11 12 void update() 13 { 14 player = GameObject.Find("Chara"); 15 } 16 17 void OnTriggerEnter(Collider col) 18 { 19 if(col.gameObject.tag == "Player") 20 { 21 if (Jump) 22 { 23 Debug.Log(test); 24 player.GetComponent<Rigidbody>().AddForce(transform.up * Time.deltaTime, ForceMode.Impulse); 25 } 26 } 27 } 28} 29
試したこと
Hierarchyでの名前を変えてみたり
別のタグで試してみたり
補足情報(FW/ツールのバージョンなど)
Unity 20182.5f1 Personal(64bit)
↓プレイヤーオブジェクトとジャンプ台にしたいオブジェクトのInspectorです
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。