- Home /
Question by
jamesasrah · Oct 26, 2017 at 01:20 PM ·
multiplayerrespawningdie
multiplayer die and respawn
i am trying to make a multiplayer team deathmatch game but i have a problem. when player other then host died the the player still can use the playercontrol and player shoot that i disable . but it still respawn with full hp except it spawn in the same spot as it died
private void Die() {
isDead = true;
for (int i = 0; i < disableOnDeath.Length; i++)
{
disableOnDeath[i].enabled = false;
}
Collider _col = GetComponent<Collider>();
if (_col != null)
_col.enabled = false;
Debug.Log(transform.name + " is DEAD!");
GameObject _GraphicInstance = (GameObject)Instantiate(DeathEffect, transform.position, Quaternion.identity);
Destroy(_GraphicInstance, 3f);
StartCoroutine(Respawn());
score.AddTeamScore(1);
}
private IEnumerator Respawn()
{
yield return new WaitForSeconds(GameManager.instance.matchSettings.respawnTime);
SetDefaults();
Transform _spawnPoint = NetworkManager.singleton.GetStartPosition();
transform.position = _spawnPoint.position;
transform.rotation = _spawnPoint.rotation;
Debug.Log(transform.name + " respawned.");
}
Comment