Unityで玉を前に飛ばそうと思ったんですけど、前に行かずに出てきた場所で止まってるんです。どうしたらいいでしょうか?
Unityで玉を前に飛ばそうと思ったんですけど、前に行かずに出てきた場所で止まってるんです。どうしたらいいでしょうか? using System.Collections; using System.Collections.Generic; using UnityEngine; public class Shoting : MonoBehaviour { GameObject gun, ammo, muzzle; public float ammoSpeed = 1000f, shootRepeat = 0.2f; // Start is called before the first frame update void Start() { gun = GameObject.Find("M4A1 Sopmod"); ammo = GameObject.Find("ammo"); muzzle = GameObject.Find("Muzzle"); } // Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { InvokeRepeating("Shoot", 0f, shootRepeat); } else if (Input.GetMouseButtonUp(0)) { CancelInvoke("Shoot"); } } void Shoot() { GameObject ballet = Instantiate(ammo, new Vector3(muzzle.transform.position.x, muzzle.transform.position.y, muzzle.transform.position.z), gun.transform.rotation); ammo.GetComponent<Rigidbody>().AddForce(ballet.transform.forward * ammoSpeed); } } ↑プログラムです。 一応こんな感じです。エラーは何にも出てません。