Shooting behavior
The next thing we will do is give our player the ability to shoot:
- Open up the
PlayerBehaviour
script. 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; // The buttons that we can use to shoot lasers public List<KeyCode> shootButton;
One thing you may have noticed is that we have a
laser
variable that is of the typeTransform
. This ...
Get Unity Game Development Blueprints now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.