Extending the PlayerSpawner script
If an item is purchased from our shop scene, this will affect what happens to our game scene when our player's ship loads into the game. Our current PlayerSpawner
script will not accommodate the shop
scene ship, so we need to revisit this script to update its CreatePlayer
method:
- In the Unity Editor's Project window, locate and open the
PlayerSpawner
script (Assets/Script
). - At the top of the
PlayerSpawner
script, with the other variables, add abool
value:bool upgradedShip = false;
The upgradedShip
Boolean will switch to true
if a modified player ship is found in the level.
- Scroll down to the
Start
function in thePlayerSpawner
script and add this as the last line with theStart
function:GetComponentInChildren<Player>().enabled = true; GameManager.Instance.CameraSetup();
Currently, our PlayerShipBuild
script disables the Player
script in the shop
scene, to stop the player from shooting in the shop...