public override SteeringOutput CalculateSteering(SteeringAgent agent) { SteeringOutput output = new SteeringOutput(); Vector3 linearVelocity = (_target - agent.transform.position).normalized; if ((_target - agent.transform.position).sqrMagnitude > (_nearEnoughDist * _nearEnoughDist)) { linearVelocity *= agent.GetMaxLinearVelocity(); } else { linearVelocity *= 0.01f; } output.LinearVelocity = linearVelocity; return(output); }
public override SteeringOutput CalculateSteering(SteeringAgent agent) { Vector3 offset = agent.RigidB.velocity; offset.Normalize(); offset *= _offset; Vector3 circleOffset = new Vector3(Mathf.Cos(_wanderAngle) * _radius, 0f, Mathf.Sin(_wanderAngle) * _radius); _wanderAngle += Random.Range(0f, 1f) * _maxAngleChange - (_maxAngleChange * 0.5f); Vector3 newTarget = agent.transform.position + offset + circleOffset; SteeringOutput output = new SteeringOutput(); Vector3 linearVelocity = (newTarget - agent.transform.position).normalized; linearVelocity *= agent.GetMaxLinearVelocity(); output.LinearVelocity = linearVelocity; return(output); }