예제 #1
0
        // Implement this OnDrawGizmosSelected if you want to draw gizmos only if the object is selected
        private void OnDrawGizmosSelected()
        {
            Gizmos.color = Color.blue;

            foreach (Vector3 direction in SteeringAgentHelper.DirectionsInCone(this, true))
            {
                Gizmos.DrawSphere(transform.position + direction, .1f);
            }
        }
예제 #2
0
        public override Vector3 Calculate(SteeringAgent _agent)
        {
            Vector3 force = _agent.CurrentForce;

            foreach (Vector3 direction in SteeringAgentHelper.DirectionsInCone(_agent))
            {
                if (Physics.Raycast(_agent.Position, direction, out RaycastHit hit, viewDistance))
                {
                    // Visualise the collision
                    Debug.DrawLine(_agent.Position, hit.point, Color.red);

                    // Interpolate the normal by the forward over the normalRatio variable
                    force += Vector3.Lerp(_agent.Forward, hit.normal, normalRatio);
                }
            }
            // f**k the force
            return(force);
        }