弾の発射をしたいです。

弾を発射したいのですが13行目でnullがでてしまいます。
https://kaleido-blog.com/unity_2d_shooting_bullet/
こちらのサイトを参考にさせていただきました。

エラーメッセージ NullReferenceException: Object reference not set to an instance of an object Shot.Start () (at Assets/Shot.cs:13) ### 該当のソースコード using System.Collections; using System.Collections.Generic; using UnityEngine; public class Shot : MonoBehaviour { public float Speed = 7.0f; public GameObject tama; public float MoveSpeed = 20.0f;// 移動値 Vector3 shotPoint; void Start() { shotPoint = transform.Find("Shotpoint").localPosition; Instantiate(tama, transform.position + shotPoint, Quaternion.identity); } public void Update() { if (Input.GetKeyDown(KeyCode.Space)) { Instantiate(tama); } transform.Translate(MoveSpeed * Time.deltaTime, 0, 0); } } c#

コメントを投稿

0 コメント