###前提・実現したいこと
unityでFPSを作っています、今銃から弾を発射するscriptで悩んでいます。
###発生している問題・エラーメッセージ
scriptを作成後bullet,nozzleに該当してるprefabを入れても弾が速度をもって飛びません。
エラーメッセージ なし ###該当のソースコード ```C# using UnityEngine; using System.Collections; public class SC_bullet : MonoBehaviour { public GameObject bullet; public Transform bullet1; public Transform muzzle; public float speed = 1000f; // Use this for initialization void Start () { } // Update is called once per frame void Update () { if (Input.GetButton("Fire1")) { GameObject.Instantiate (bullet, muzzle.position, bullet1.rotation); Vector3 direction = (muzzle.position - transform.position).normalized; bullet.GetComponent<Rigidbody>().velocity = direction; } } } ###試したこと FPSで銃のノズルから弾を発射したいです。 ###補足情報(言語/FW/ツール等のバージョンなど) unity
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/06/18 13:05