- Home /
Destroy gameObject on collision/time?
Hello, I need to add a destroy bullet gameobject script into my shooting script for my FPS game. Currently it laggs and keeps building up. So please reply with the proper destroy gameobject (after 5 secs or so) and where I should place the script in my shooting script. Thanks =D
heres my script :
var speed = 20;
function Update(){ if (Input.GetButtonDown("Fire1") && (Time.time <= nextFire)) { nextFire = Time.time + fireRate; } if(Input.GetButton("Fire1") && (Time.time > nextFire)) { nextFire = Time.time + fireRate; Fire(); } }
function Fire()
{
var instantiatedProjectile : Rigidbody = Instantiate(
projectile, transform.position, transform.rotation );
instantiatedProjectile.velocity =
transform.TransformDirection( Vector3( 0, 0, speed ) );
Physics.IgnoreCollision( instantiatedProjectile. collider,
transform.root.collider );
CancelInvoke();
}
Can you format your code correctly, please? There is a small binary-looking (0's and 1's) button in the toolbar. Click that and past your code in there, then hit enter.
Your answer
Follow this Question
Related Questions
Help with game, stopping player cheating (script help) 1 Answer
error CS1061 anybody might help me? 1 Answer
click shooting how do i do it? 1 Answer
Shoot. Just Shoot 5 Answers
check a object is parent or not? 1 Answer