Graphics Reference
In-Depth Information
Player_Parent_Object
When the player is spawned by the game controller, it will be parented to this object. In
turn, as this object is parented to the camera, the player will always move along with
the camera.
StarsLayer1
Particle effects used to simulate stars in the background. This effect moves along with
the camera, and the particles move down to look as though it is a constant movement
through space.
If the Boolean variable isStopped is set to true, the camera will not be moved further
through the level. This is used at the end of the level during the boss battle. The Translate
function only requires a movement vector, which is multiplied by Time.deltaTime, in
this case, to make sure that the movement is time based:
public void LateUpdate ()
{
if(!isStopped)
{
// do fly movement through the level
CameraTransform.Translate( Vector3.up *
Time.deltaTime * levelForwardSpeed );
}
}
StartPlayer() is scheduled by the Init() function to be called several seconds after
the level first loads. Until this point, the player (or players) will be held in place. This
function starts out by grabbing references to the Player_SpaceShip_IP component with
Unity's GameObject.GetComponent(), followed by another GetComponent() call to find
the DataManager component (the BasePlayerManager and DataManager scripts were dis-
cussed back in Chapter 3):
public void StartPlayer ()
{
Debug.Log ("StartPlayer!!!");
// find the player's control script and hold it in
// playerScript
playerScript1= playerGO1.GetComponent<Player_SpaceShip_IP>();
mainPlayerDataManager1=
playerGO1.GetComponent<BasePlayerManager>().DataManager;
Now that references have been stored for playerScript1 and mainPlayerDataManager1,
a message is sent to the player's control script component to call its GameStart() function.
GameObject.SendMessage() is used to send it:
// all ready to play, let's go!
playerGO1.SendMessage( "GameStart" );
If there is more than one player, the game controller is going to need to know how
and where to talk to the second player. This part of the script grabs the same component
Search WWH ::




Custom Search