nosymmetree / Asteroids_Add-ons

Adding some small features for an Asteroids game I created
0 stars 0 forks source link

Spaceship is not shooting #2

Open nosymmetree opened 11 years ago

nosymmetree commented 11 years ago

I cannot make the spaceship shoot the laser

nosymmetree commented 11 years ago

in playerController.js:

var laserPrefab:Rigidbody;

    //fire at left apple key
    if(Input.GetKeyDown(KeyCode.LeftControl)){

        //create a bullet at th position of the spaceship
        Instantiate(laserPrefab,transform.position,transform.rotation);
        //the laser shot counter 
        laserShots++;
        //audiosource for the laser being shot
        GetComponent(AudioSource).clip = laserSounds[ Random.Range(0,laserSounds.Length)];
        GetComponent(AudioSource).Play();

    }