If there's a top tier door in that position-radius for some reason Vis.Entities finds it two times.Code:List<BaseEntity> nearby = new List<BaseEntity>(); Vis.Entities(player.transform.position, 3f, nearby, LayerMask.GetMask("Construction"), QueryTriggerInteraction.Ignore); foreach (BaseEntity entity in nearby) { PrintToChat(entity.ShortPrefabName); PrintToChat(entity.transform.position.ToString()); if (entity as Door == null) continue; if (entity.ShortPrefabName != "door.hinged.toptier") continue; }
This doesn't happend with a wood door.
No idea why.
Solved Vis.Entities finding two doors
Discussion in 'Rust Development' started by Reynostrum, Nov 18, 2016.
-
You can filter duplicates by "Distinct":
Code:List<BaseEntity> nearby = new List<BaseEntity>(); Vis.Entities(player.transform.position, 3f, nearby, LayerMask.GetMask("Construction"), QueryTriggerInteraction.Ignore); foreach (BaseEntity entity in nearby.Distinct().ToList()) { PrintToChat(entity.ShortPrefabName); PrintToChat(entity.transform.position.ToString()); if (entity as Door == null) continue; if (entity.ShortPrefabName != "door.hinged.toptier") continue; } -
Solved. Thank you Fuji.
Just for curiosity, do you know why is this happening? -
I had this issue recently, did exactly what Fujikura did to solve it, lol.
I'm curious as to what causes it as well, since I believe it's only started happening recently -
Had the same problem before on a direct call of "Physics.OverlapSphere" while checking cupboards in range. Does also return on some cases some of them twice.
