var bullitPrefab:Transform;
function Update ()
{
var bullit = Instantiate(bullitPrefab ,transform.Find(“Boom”). transform.position ,
Quaternion.identity);
//shoot when i click the left mouse key
bullit.rigidbody.AddForce(transform.forward * 2000);
}
i have 4 problems one the bullits shoot out like 30 at a time second thay are coming out of the side of the spawn piont and how can i make it to were wen i left click the mouse it shoots and if i hold it shoots rapid and how do i make the bullits diapear after 2 seconds
2 mak ur bullits go fater
… okay, I can’t do that. It hurts too much.
Spelling grammar etc.
var bulletPrefab : Transform; // what a bullet is
var bulletSource : Transform; // where bullets come from
var bulletForce : float = 2000.0; // how fast the bullet is shot
private var nextFireTime : float; // when can we shoot again
var rapidFireDelay : float = 0.2; // delay between shots
var reloadTime : float = 1.0; // time it takes to reload
private var clip : int; // ammo remaining in clip
var ammoPerClip : int = 5;
function Start() {
clip = ammoPerClip;
}
function Update() {
if ( Input.GetButton( "Fire1" ) ) {
if ( nextFireTime <= Time.time ) {
nextFireTime = Time.time + rapidFireDelay;
ShootOnce();
}
}
}
function ShootOnce() {
clip--;
if ( clip < 0 ) Reload();
else {
var bullet : GameObject = Instantiate( bulletPrefab, bulletSource.position, bulletSource.rotation );
bullet.rigidbody.AddForce( bulletSource.forward * bulletForce );
}
}
function Reload() {
clip = ammoPerClip;
nextFireTime = Time.time + reloadTime;
}