Graphics Reference
In-Depth Information
// stop movement, as long as rigidbody is not
// kinematic (otherwise it will have no velocity and we
// will generate an error message trying to set it)
if( !myPlayerController.rigidbody.isKinematic )
myPlayerController.rigidbody.velocity=Vector3.zero;
// hide ship body
theMeshGO.SetActive(false);
// disable and hide weapon
weaponControl.DisableCurrentWeapon();
// do anything we need to do at game finished
PlayerFinished();
} else {
// hide ship body
theMeshGO.SetActive(false);
// disable and hide weapon
weaponControl.DisableCurrentWeapon();
// respawn
Invoke("Respawn",2f);
}
}
void Respawn()
{
// reset the 'we are respawning' variable
isRespawning= false;
// we need to be invulnerable for a little while
MakeInvulnerable();
Invoke ("MakeVulnerable",3);
// show ship body again
theMeshGO.SetActive(true);
// revert to the first weapon
weaponControl.SetWeaponSlot(0);
// show the current weapon (since it was hidden when the
// ship explosion was shown)
weaponControl.EnableCurrentWeapon();
}
void OnCollisionEnter(Collision collider)
{
// MAKE SURE that weapons don't have colliders
// if you are using primitives, only use a single collider
// on the same gameobject which has this script on
// when something collides with our ship, we check its layer
// to see if it is on 11 which is our projectiles
// (Note: remember when you add projectiles set the layer
correctly!)
if(collider.gameObject.layer==11 && !isRespawning &&
!isInvulnerable)
Search WWH ::




Custom Search