mirror of
https://github.com/Xevion/Boids.git
synced 2025-12-11 04:06:35 -06:00
Boid optimize/fix wrapping checks
This commit is contained in:
@@ -23,11 +23,7 @@ public class Boid : MonoBehaviour {
|
||||
transform.rotation = Quaternion.Euler(0, 0, Mathf.Rad2Deg * -Mathf.Atan2(velocity.x, velocity.y));
|
||||
|
||||
// Skip Flock Calculations if wrapping in progress
|
||||
if (IsWrappingX || IsWrappingY) {
|
||||
position += velocity;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsWrappingX && !IsWrappingY) {
|
||||
// Acquires all Boids within the local flock
|
||||
// List<Boid> flock = GetFlock(parent.boids, parent.boidGroupRange);
|
||||
List<Boid> flock = parent.boids;
|
||||
@@ -45,9 +41,14 @@ public class Boid : MonoBehaviour {
|
||||
velocity = (velocity / velocity.magnitude) * parent.boidVelocityLimit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Update 2D and 3D transform positions based on current velocity
|
||||
position += velocity;
|
||||
transform.position = new Vector3(position.x, position.y, 0);
|
||||
|
||||
// If either dimension of wrapping is still unlocked, check wrapping code.
|
||||
if(!IsWrappingX || !IsWrappingY)
|
||||
Wrapping();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user