Fix GetClosestTo bug(?)
This commit is contained in:
parent
cc360b3932
commit
ae54f85722
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user