Hey guys,
i have been banging my head here for a while here now with a (probably) simple problem.
i wanted to detect my players using spherecasts and send those to my client but for some reason my assigned objects arent detected.
i know for sure they are properly assigned to that layer, any ideas whats wrong here?
// Player initiation
public void Initialize(int _id, string _username)
{
id = _id;
username = _username;
this.gameObject.layer = LayerMask.NameToLayer("Players");
Debug.Log($"Set player to layer #{this.gameObject.layer}");
Debug.Log($"Objects on player layer:{string.Join(",", Resources.FindObjectsOfTypeAll(typeof(GameObject)).Where(i => (i as GameObject).layer == 8).Select(i => (i as GameObject).name))}");
inputs = new bool[6];
}
// SphereCast detection.
private void SendPlayersAroundPlayer()
{
foreach (RaycastHit hit in Physics.SphereCastAll(this.transform.position, 50f, Vector3.forward, 50f, LayerMask.NameToLayer("Players")))
{
Debug.Log(hit.transform.name); // Never gets printed cause SphereCastAll returns 0 hits
//ServerSend.SendPlayer(id, hit.transform.GetComponent<Player>());
}
ServerSend.SendPlayer(this.id, this);
}