Graphics Reference
In-Depth Information
// tell game controller to do a nice big explosion
GameController_MVD.Instance.PlayerBigHit(myTransform );
After the explosion, the player will respawn 4 s later:
// respawn
Invoke("Respawn",4f);
In this game, the player will always be respawned with full health since the goal is not
to win a battle but to make it to the finish line first. myDataManager contains a function
to directly set health, which is used to restore its value to that of startHealthAmount:
// reset health to full
myDataManager.SetHealth(startHealthAmount);
} else {
If the player's data manager health value is not yet at 0, there's much less drama in
the reaction. Instead of a large explosion, we just tell the game controller to make a small
particle effect via its PlayerHit() function:
// tell game controller to do small scale hit
GameController_MVD.Instance.PlayerHit( myTransform );
}
}
When the player is respawned, its position and rotation will be reset, and it is also
important to reset its velocity and angular velocity so that the vehicle does not continue
to flip or rotate after:
void Respawn()
{
// reset the 'we are respawning' variable
isRespawning= false;
// reset our velocities so that we don't reposition a
// spinning vehicle
myBody.velocity=Vector3.zero;
myBody.angularVelocity=Vector3.zero;
The race controller provides a waypoint suitable for using to respawn with from the
GetRespawnWaypointTransform() function:
// get the waypoint to respawn at from the race controller
tempTR= raceControl.GetRespawnWaypointTransform();
tempVEC= tempTR.position;
Waypoints are not always positioned in exactly the right position above the ground,
so to make things work a little better, the script uses a raycast straight down from above the
waypoint, to find the ground and try to position the vehicle in a good place:
// cast a ray down from the waypoint to try to find the
// ground
Search WWH ::




Custom Search