- Home /
Question by
Snakeman57 · Jun 18, 2015 at 07:14 PM ·
shootinggunshootguns
How to make a gun in unity?
So I have this code:
using UnityEngine;
using System.Collections;
public class scrPlayerFire : MonoBehaviour{
public GameObject bullet;
public Transform spawn;
void update(){
if(Input.GetKey (KeyCode.Space)){
Instantiate(bullet, spawn.position, spawn.rotation);
}
}
}
I made a prefab linked to bullet that has code to move it forward, and I've made an empty object to use for the transform. but when i press space nothing happens. What am I doing wrong?
Comment
Your answer
Follow this Question
Related Questions
Problems with a shooting script 1 Answer
Shooting & Animation Problem 1 Answer
not losing ammo when shooting 1 Answer
Shooting script not working properly 3 Answers
1 script doesn't react to input 1 Answer