Graphics Reference
In-Depth Information
count3.SetActive( false );
}
void ShowCount2 ()
{
count1.SetActive( false );
count2.SetActive( true );
count3.SetActive( false );
}
void ShowCount3 ()
{
count1.SetActive( false );
count2.SetActive( false );
count3.SetActive( true );
}
HideCount() hides all three of the UI objects from the 3-2-1 countdown:
void HideCount ()
{
count1.SetActive( false );
count2.SetActive( false );
count3.SetActive( false );
}
To hide or show a message to the user that the main player is driving the wrong way
on the track, the UpdateWrongWay() function uses GameObject.SetActive(). For that rea-
son, the user interface objects active states only need to be updated whenever there is a
change, as opposed to constant resetting. To track the changes, oldIsWrongWay holds the
value of isWrongWay but only gets set if it is not the same. We can decide early on to drop
out of the function, whenever isWrongWay is equal to oldIsWrongWay:
public void UpdateWrongWay ( bool isWrongWay )
{
if( isWrongWay==oldIsWrongWay)
return;
If the script execution reaches this point, the value of wrong way must have changed
so the script may go ahead and set the active state of the UI gameObject referenced by
wrongWaySign:
if ( isWrongWay )
{
wrongWaySign.SetActive( true );
}
else
{
wrongWaySign.SetActive( false );
}
oldIsWrongWay=isWrongWay;
}
The PlayerHit() and PlayerBigHit() functions are not required for a racing game, but
they are here for a good reason. What they do is play an explosion sound effect and call
the Explode() function to instantiate a small particle effect. When the weapons system in
Search WWH ::




Custom Search