- Home /
projectile limitation problems
hi guys i have a thirdperson player to shoot down objects but the problem is the player shoot outs projectiles for awhile and can't shoot anymore.
here is my projectile script that attached to the player:
function LateUpdate (){
if(Input.GetButtonDown("Fire1"))
{
//nextFire = Time.time + fireRate;
var bullit = Instantiate(bullitPrefab,
transform.Find("spawnpoint").transform.position,Quaternion.identity);
bullit.tag="fireProjectile";
bullit.rigidbody.AddForce(transform.forward * 200);
audio.PlayOneShot(shootSound);
}
}
this is the script that attached to the prefab: var lifetime = 1.0;
function Awake(){
Destroy(gameObject,lifetime);
}
function OnCollisionEnter(hit:Collision)
{
(hit.tag.gameObject =="bombgy");
Destroy(gameObject);
} Really appreciate everyones"s help who try to help me in this problems.
Answer by roamcel · Oct 27, 2011 at 09:44 AM
This doesn't look like it can actually stop the shooting. I'm led to believe that there's something else going on.
For example: are you sure that 'bullitprefab' is an actual prefab, instead of an instance in the scene?
That's what I was suspecting too - if the bullitPrefab is a scene object, it may get destroyed and nothing more will be shot - except runtime errors! The projectile script also has a very weird line:
(hit.tag.gameObject == "bombgy");
This should not even compile, but if it passed due to some internal compiler bug, the projectile would be destroyed when hitting anything - what could kill the bullitPrefab if it was a scene object.
Your answer
Follow this Question
Related Questions
Slow automatic shooting script? 2 Answers
Projectile Script 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Shooting Script Bullet Doesnt Fire 2 Answers
Shooting in 2 dimensional games 2 Answers