Hi, I’ve been given this nice bit of code by someone nice on here - and I’m really struggling with it. It’s meant to count my players that get the ‘dead’ variable (which should turn on when they fall off edge and collide with the floor - I’ve got a feeling it might be global, and not only on the object though, which may need to fix). I also don’t really understand the top part, could someone please shed some light on it, please? If someone does rewrite it - UnityScript or C#, it doesn’t matter, I’ve a terrible knowledge of both ![]()
I’m super new to this, thanks ![]()
/* Hooks in said variable count */ static var dead : int = 0; /* Update on each frame */ function Update() { var dead /*Players*/ : int = 0; /* Declaring that var i is int (which is 0) */ for (var i: int = 0) // I don't understand at all // ++ is add one each time, isn't it? i<_players.Length; i++) { if (_players*.dead)*
> deadPlayers++;
> }
>
> /* Counts dead Players - if >=3, do next */
> if (deadPlayers >= 3)
>
> /*Load Level */
> Application.LoadLevel(1);
> }
&
> // Static Var makes public
> static var dead = false;
>
> // does the dead tag apply globally? or just to the object that
> collided?
> // Because I want it just on the object
>
> function OnTriggerEnter (other : Collider)
> {
> dead = true;
> Debug.Log (other.gameObject.name);
> }
TLDR:
Can someone explain to me the top part of code/fix it for me?
Does the bottom bit of code make the dead variable global, or just on the object collided - How can I change that?
Do I need to declare my characters, so they can be counted?