script help
So i have a script for death when health is at 0 but it is an online game and i set it so when the player dies it goes to a different scene. But when you shoot another player until the player is dead all of the players go to the different scene even though only 1 player died. If anyone can help me with this it would be greatly appreciated thanks!
Answer by LordRechy · Dec 19, 2015 at 03:21 AM
I havent tried any yet... i got the death script but i cant put it so everyone doesnt die. i can give you the death script though.
using UnityEngine; using UnityEngine.Networking;
public class Player : NetworkBehaviour {
[SerializeField]
private int maxHealth = 100;
[SyncVar]
private int currentHealth;
void Awake ()
{
SetDefaults();
}
public void TakeDamage (int _amount)
{
currentHealth -= _amount;
Debug.Log(transform.name + " now has " + currentHealth + " health.");
}
public void SetDefaults ()
{
currentHealth = maxHealth;
}
void Update () {
if (currentHealth < 0)
Application.LoadLevel ("Scne2");
}
}
thats it but i need it so it works on individual players that get spawned in.
Your answer
Follow this Question
Related Questions
The laser problems 0 Answers
How can i make sure the script will work only on the attached object ? 1 Answer
How can I check if a object in the hierarchy have been destroyed using EditorWindow type script ? 1 Answer
How do i put "Wasted!" after respawn? 0 Answers
Reverse memcpy for NativeArray? 0 Answers