Quantcast
Channel: Questions in topic: "gun"
Viewing all articles
Browse latest Browse all 592

Need help with my gun script!

$
0
0
I made a shooting script but when I shoot the gun it shoots really fast and it shoots a lot of bullets at once. I only want it to shoot one bullet every time. Here is my script. using UnityEngine; using System.Collections; public class Shoot : MonoBehaviour { public Rigidbody bulletPrefab; public Transform spawnPoint; public int speed; // Use this for initialization void Start () { } // Update is called once per frame void Update () { if(Input.GetKey(KeyCode.Mouse0)) { Rigidbody bulletInstance; bulletInstance = Instantiate(bulletPrefab, spawnPoint.position, Quaternion.identity) as Rigidbody; bulletInstance.AddForce(spawnPoint.forward * speed); } } } And could somebody tell me how to make it where the bullet doesn't go on it's side. When I shoot the bullet goes forward but the bullet will face down.

Viewing all articles
Browse latest Browse all 592

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>