Fix GetClosestTo bug(?)

This commit is contained in:
Jens Pitkänen 2019-08-15 01:26:56 +03:00
parent cc360b3932
commit ae54f85722

View File

@ -7,8 +7,7 @@ namespace Saltosion.OneWeapon.Utils {
float LowestDistance = float.PositiveInfinity;
T FoundTarget = null;
foreach (Collider2D Collider in NearbyColliders) {
if (Collider.gameObject == Searcher.gameObject ||
(Collider.attachedRigidbody != null && Collider.attachedRigidbody.gameObject == Searcher.gameObject)) {
if (Collider.gameObject == Searcher.gameObject) {
continue;
}
@ -21,7 +20,8 @@ namespace Saltosion.OneWeapon.Utils {
if (needsLineOfSight) {
LineOfSightObstructed = false;
foreach (RaycastHit2D Hit in Hits) {
if (Hit.collider != Collider && Hit.transform != Searcher) {
if (Hit.collider != Collider && Hit.transform != Searcher &&
(Hit.rigidbody == null || Hit.rigidbody.transform != Searcher)) {
// Hit something between the target and the searcher
LineOfSightObstructed = true;
break;