2
0
Fork 0
mirror of https://github.com/GTA-ASM/SanAndreasUnity synced 2025-02-19 14:28:28 +00:00

improvement

This commit is contained in:
in0finite 2019-06-25 22:26:38 +02:00
parent a1be18c3ce
commit 69042ae62e

View file

@ -30,21 +30,15 @@ namespace SanAndreasUnity.Behaviours
if (Camera.main != null)
focusPoints = focusPoints.Append(Camera.main.transform);
if (!focusPoints.Any()) {
// no focus points
// don't do anything
// check if we are in range of any focus point
Vector3 thisPosition = this.transform.position;
bool isInRange = focusPoints.Any(point => point.Distance(thisPosition) < this.range);
if (isInRange) {
this.timeSinceOutOfRange = 0;
} else {
// check if we are in range of any focus point
Vector3 thisPosition = this.transform.position;
bool isInRange = focusPoints.Any(point => point.Distance(thisPosition) < this.range);
if (isInRange) {
this.timeSinceOutOfRange = 0;
} else {
this.timeSinceOutOfRange += 1.0f;
}
this.timeSinceOutOfRange += 1.0f;
}
if (this.timeSinceOutOfRange >= this.timeUntilDestroyed) {
// timeout expired
Destroy(this.gameObject);