Fix GetClosestTo bug(?)
This commit is contained in:
parent
cc360b3932
commit
ae54f85722
@ -7,8 +7,7 @@ namespace Saltosion.OneWeapon.Utils {
|
|||||||
float LowestDistance = float.PositiveInfinity;
|
float LowestDistance = float.PositiveInfinity;
|
||||||
T FoundTarget = null;
|
T FoundTarget = null;
|
||||||
foreach (Collider2D Collider in NearbyColliders) {
|
foreach (Collider2D Collider in NearbyColliders) {
|
||||||
if (Collider.gameObject == Searcher.gameObject ||
|
if (Collider.gameObject == Searcher.gameObject) {
|
||||||
(Collider.attachedRigidbody != null && Collider.attachedRigidbody.gameObject == Searcher.gameObject)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,7 +20,8 @@ namespace Saltosion.OneWeapon.Utils {
|
|||||||
if (needsLineOfSight) {
|
if (needsLineOfSight) {
|
||||||
LineOfSightObstructed = false;
|
LineOfSightObstructed = false;
|
||||||
foreach (RaycastHit2D Hit in Hits) {
|
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
|
// Hit something between the target and the searcher
|
||||||
LineOfSightObstructed = true;
|
LineOfSightObstructed = true;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user