Graphics Reference
In-Depth Information
// respawn
Invoke("Respawn",4f);
// reset health to full
myDataManager.SetHealth(startHealthAmount);
} else {
// tell game controller to do small scale hit
GameController_MVD.Instance.PlayerHit( myTransform );
}
}
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;
// get the waypoint to respawn at from the race controller
tempTR= raceControl.GetRespawnWaypointTransform();
tempVEC= tempTR.position;
// cast a ray down from the waypoint to try to find the
// ground
RaycastHit hit;
if(Physics.Raycast(tempVEC + (Vector3.up * 300), -Vector3.up,
out hit)){
tempVEC.y=hit.point.y+15;
}
// reposition the player at tempVEC (the waypoint position
// with a corrected y value via raycast)
// and also we set the player rotation to the waypoint's
// rotation so that we are facing in the right
// direction after respawning
myTransform.rotation= tempTR.rotation;
myTransform.position= tempVEC;
// we need to be invulnerable for a little while
MakeInvulnerable();
Invoke ("MakeVulnerable",3);
// revert to the first weapon
if( weaponControl!=null )
weaponControl.SetWeaponSlot(0);
}
void MakeInvulnerable()
{
isInvulnerable=true;
}
Search WWH ::




Custom Search