Graphics Reference
In-Depth Information
// call the explosion function!
Explode( whichPlayer.position );
}
public void PlayerBigHit(Transform whichPlayer)
{
// tell our sound controller to play an explosion sound
BaseSoundController.Instance.PlaySoundByIndex( 2,
whichPlayer.position );
// call the explosion function!
Explode( whichPlayer.position );
}
public void Explode ( Vector3 aPosition )
{
// instantiate an explosion at the position passed into this
// function
Instantiate( explosionPrefab,aPosition, Quaternion.identity );
}
}
12.3.1.1 Script Breakdown
The script derives from BaseGameController.cs:
using UnityEngine;
using System.Collections;
public class GameController_MVD : BaseGameController
{
The variable Instance is set to this instance of the script when it is first created and the
script's constructor gets called:
public GameController_MVD ()
{
Instance = this;
}
A call to Init() is made:
void Start ()
{
Init();
}
The Init() function starts by setting Time.timeScale, in this example game gameSpeed
is set to make the game run a little faster:
void Init ()
{
// in case we need to change the timescale, it gets set here
Time.timeScale = gameSpeed;
Search WWH ::




Custom Search