diff --git a/Assets/Scripts/Character.cs b/Assets/Scripts/Character.cs index b91bf88..e351270 100644 --- a/Assets/Scripts/Character.cs +++ b/Assets/Scripts/Character.cs @@ -305,21 +305,28 @@ public class Character : MonoBehaviour void OnTriggerEnter(Collider other) { Collectable collectable = other.GetComponentInChildren(); + blockSpawn spawn = GetComponent(); if (collectable != null) { - collectable.OnCollect(this); - } - if (other.gameObject.name == "collect_sphere") - { - other.gameObject.SetActive(false); - //player.collected +=1; + //get position from average; + ClientList list = spawn.clientDataList; + float average = 0; + int livePlayerCount = 0; + foreach (ClientData data in list.ConnectedClients) + { + if (data.Lives > 0) + { + average += data.playerCharacter.transform.position.x; + livePlayerCount++; + } + } + average /= livePlayerCount; + float tosend = lives + (transform.position.x - average); - } - if (other.gameObject.name == "End Portal") - { - other.GetComponent().enabled = false; - SceneManager.LoadScene(nextScene); + spawn.assignLogicBlock(collectable.gameObject, tosend); + + collectable.OnCollect(this); } }