mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2025-02-19 14:28:28 +00:00
improvement
This commit is contained in:
parent
a1be18c3ce
commit
69042ae62e
1 changed files with 7 additions and 13 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue