Transitioning our player ship
Currently, our levels can only be completed when the player dies, causing the level to restart, or when the player loses all three lives. Only then are we taken to the game over screen. We now need to start thinking of how a player starts and ends a level. Currently, the player just appears at the start of a level.
In this section, we are going to write some code that animates our player into the scene and, when the level completes, we will have the player ship exit the camera view.
So, let's make a script the same way we did all the other scripts (Chapter 2, Adding and Manipulating Objects, if you need a reference). Name the script PlayerTransition and make sure we have the file in our Script folder in the Unity Editor Project window.
We now need to attach the PlayerTransition script to our player_ship prefab:
- Load up the
testLevelscene fromAssets/Scenein the Project window. - Then, navigate to the
Assets/Prefab/Playerfolder...