public Vector2 ComputeForce() { Vector2 desired = TargetPosition - Agent.Position; float distance = desired.Length(); desired.Normalize(); Vector2 steeringVec; if (distance < SlowingRadius) { float mag = OrionMath.Map(distance, 0, 100, 0, Agent.MaxSpeed); desired *= mag; steeringVec = desired - Agent.Velocity; steeringVec = OrionMath.VectorTruncate(steeringVec, Agent.MaxDeceleration); } else { desired *= Agent.MaxSpeed; steeringVec = desired - Agent.Velocity; steeringVec = OrionMath.VectorTruncate(steeringVec, Agent.MaxAcceleration); } return(steeringVec); }
public Vector2 ComputeForce() { Vector2 desiredVelocity = OrionMath.VectorNormalize(TargetPosition - Agent.Position) * Agent.MaxSpeed; Vector2 steeringVec = desiredVelocity - Agent.Velocity; steeringVec = OrionMath.VectorTruncate(steeringVec, Agent.MaxAcceleration); return(steeringVec); }
private Vector2 Seek(Vector2 target) { Vector2 desiredVelocity = OrionMath.VectorNormalize(target - Agent.Position) * Agent.MaxSpeed; Vector2 steeringVec = desiredVelocity - Agent.Velocity; steeringVec = OrionMath.VectorTruncate(steeringVec, Agent.MaxAcceleration); return(steeringVec); }