The next thing we will do is give our player the ability to shoot:
PlayerBehaviourscript. In the top section where the other variables are present, we need to add some additional ones that we'll use:
// The laser we will be shooting public Transform laser; // How far from the center of the ship should the laser be public float laserDistance = .2f; // How much time (in seconds) we should wait before // we can fire again public float timeBetweenFires = .3f; // If value is less than or equal 0, we can fire private float timeTilNextFire = 0.0f;
One thing you may have noticed is that we have a
laser variable that is of the type
Transform. This is the laser we'll fire, which we will create shortly.
In our game, the player ...