Edited to deltatime
This commit is contained in:
@@ -76,9 +76,9 @@ public class BoidComponent : MonoBehaviour
|
||||
|
||||
Quaternion directionRotation = Quaternion.LookRotation(-targetDir);
|
||||
|
||||
transform.rotation = Quaternion.Slerp(transform.rotation, directionRotation, corneringSpeed);
|
||||
transform.rotation = Quaternion.Slerp(transform.rotation, directionRotation, corneringSpeed * Time.deltaTime);
|
||||
|
||||
transform.position += transform.forward * (1/(101 - speed));
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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,6 +39,11 @@ public class BoidManager : MonoBehaviour
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
foreach (BoidComponent boid in boids)
|
||||
{
|
||||
boid.Move();
|
||||
}
|
||||
|
||||
if (boidSpeed != setSpeed || boidCenterInfluence != setCenterInfluence ||
|
||||
boidBoidInfluence != setBoidInfluence || boidCorneringSpeed != setCornering)
|
||||
{
|
||||
@@ -57,9 +62,6 @@ public class BoidManager : MonoBehaviour
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
foreach (BoidComponent boid in boids)
|
||||
{
|
||||
boid.Move();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user