diff --git a/Assets/Scripts/BoidComponent.cs b/Assets/Scripts/BoidComponent.cs index e137899..f6dfeaa 100644 --- a/Assets/Scripts/BoidComponent.cs +++ b/Assets/Scripts/BoidComponent.cs @@ -76,9 +76,9 @@ public class BoidComponent : MonoBehaviour Quaternion directionRotation = Quaternion.LookRotation(-targetDir); - transform.rotation = Quaternion.Slerp(transform.rotation, directionRotation, corneringSpeed); - - transform.position += transform.forward * (1/(101 - speed)); + transform.rotation = Quaternion.Slerp(transform.rotation, directionRotation, corneringSpeed * Time.deltaTime); + + transform.position += transform.forward * (1/(101 - speed * Time.deltaTime)); } private Vector3 calcCloseBoidInteractionsV3() @@ -128,7 +128,7 @@ public class BoidComponent : MonoBehaviour angleBetweenForwards = Mathf.Rad2Deg * Mathf.Acos(angleBetweenObjects / (transform.forward.magnitude * contact.magnitude)); }*/ - if (collision.gameObject.layer == 0 && angleBetweenObjects < 180 - movementConeAngle) + if (collision.gameObject.layer == 0 && angleBetweenObjects < movementConeAngle) { //Debug.Log(dist); //avoid @@ -144,8 +144,8 @@ public class BoidComponent : MonoBehaviour Vector3 avoid = (-targetDir.normalized * 5) / (dist); desiredDirectionToLook += avoid; - Debug.DrawLine(transform.position, transform.position + avoid); - Debug.Log(avoid.magnitude); + //Debug.DrawLine(transform.position, transform.position + avoid); + //Debug.Log(avoid.magnitude); } } } @@ -216,7 +216,7 @@ public class BoidComponent : MonoBehaviour private Vector3 calcCenterInfluenceV3(Vector3 center) { - Debug.DrawLine(transform.position, center); + //Debug.DrawLine(transform.position, center); return (transform.position - center).normalized; } diff --git a/Assets/Scripts/BoidManager.cs b/Assets/Scripts/BoidManager.cs index 04ddfdf..06a29fe 100644 --- a/Assets/Scripts/BoidManager.cs +++ b/Assets/Scripts/BoidManager.cs @@ -9,7 +9,7 @@ public class BoidManager : MonoBehaviour [SerializeField] [Range(0.0001f, 1)] public float boidCenterInfluence = 0.5f; [SerializeField][Range(0.0001f, 1)] public float boidBoidInfluence = 0.5f; [SerializeField][Range(1, 100)] public float boidSpeed = 1; - [SerializeField][Range(0.0001f, 0.1f)] public float boidCorneringSpeed = 0.5f; + [SerializeField][Range(0.0001f, 1f)] public float boidCorneringSpeed = 0.5f; private float setSpeed; private float setCenterInfluence; @@ -39,7 +39,12 @@ public class BoidManager : MonoBehaviour // Update is called once per frame void Update() { - if(boidSpeed != setSpeed || boidCenterInfluence != setCenterInfluence || + foreach (BoidComponent boid in boids) + { + boid.Move(); + } + + if (boidSpeed != setSpeed || boidCenterInfluence != setCenterInfluence || boidBoidInfluence != setBoidInfluence || boidCorneringSpeed != setCornering) { foreach (BoidComponent boid in boids) @@ -57,9 +62,6 @@ public class BoidManager : MonoBehaviour private void FixedUpdate() { - foreach (BoidComponent boid in boids) - { - boid.Move(); - } + } } \ No newline at end of file