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
public void RpcTakeDamage(int _amount)
{
if (!isServer)
{
return;
}
if (isDead)
return;
currentHealth -= _amount;
Debug.Log(transform.name + " now has " + currentHealth + " health.");
currentHealth2 = currentHealth;
if (currentHealth <= 0)
{
for (int i = 0; i < disableOnDeath.Length; i++)
{
disableOnDeath[i].enabled = false;
}
Die();
}
}
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.");
}