Graphics Reference
In-Depth Information
myBody.angularVelocity=new Vector3( Random.Range
(-100,100), Random.Range (-100,100), Random.Range
(-100,100) );
// tell game controller to do a nice big explosion
GameController_TB.Instance.PlayerBigHit( myTransform
);
// respawn
Invoke("Respawn",4f);
// reset health to full
myDataManager.SetHealth(startHealthAmount);
} else {
// tell game controller to do small scale hit if we
// still have some health left
GameController_TB.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 battle controller
tempVEC= respawnPoint;
// 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.eulerAngles= respawnRotation;
myTransform.position= tempVEC;
// we need to be invulnerable for a little while
MakeInvulnerable();
Invoke ("MakeVulnerable", respawnInvunerabilityTime);
// revert to the first weapon
weaponControl.SetWeaponSlot(0);
// show the current weapon (since it was hidden when the
// ship explosion was shown)
Search WWH ::




Custom Search