when i want to shoot my gun, the first bullet will shoot fine but when i go to shoot anymore… the bullet will be half way down the screen.
My code for the FP_Shooting:
using UnityEngine;
using System.Collections;
public class FP_Shooting : MonoBehaviour {
public GameObject bullet_prefab;
float bulletImpulse = 50f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if( Input.GetButtonDown("Fire1") ) {
Camera cam = Camera.main;
GameObject thebullet = (GameObject)Instantiate(bullet_prefab, cam.transform.position + cam.transform.forward, cam.transform.rotation);
thebullet.rigidbody.AddForce( cam.transform.forward * bulletImpulse, ForceMode.Impulse);
}
}
void OnGUI(){
GUI.Box(new Rect(Screen.width/2,Screen.height/2, 10, 10), "");
}
}
Please help me.
Regards,
Micky2171
Thanks, I had typed your code wrong... It works now
– micky2171