Ejemplo n.º 1
0
        bool FindObstacle(Vector3 facingDir, out GenericCastHit firstHit)
        {
            facingDir = rb.ConvertVector(facingDir).normalized;

            /* Create the direction vectors */
            Vector3[] dirs = new Vector3[3];
            dirs[0] = facingDir;

            float orientation = SteeringBasics.VectorToOrientation(facingDir, rb.is3D);

            dirs[1] = SteeringBasics.OrientationToVector(orientation + sideWhiskerAngle * Mathf.Deg2Rad, rb.is3D);
            dirs[2] = SteeringBasics.OrientationToVector(orientation - sideWhiskerAngle * Mathf.Deg2Rad, rb.is3D);

            return(CastWhiskers(dirs, out firstHit));
        }
Ejemplo n.º 2
0
        public Vector3 GetSteering()
        {
            float characterOrientation = rb.RotationInRadians;

            /* Update the wander orientation */
            wanderOrientation += RandomBinomial() * wanderRate;

            /* Calculate the combined target orientation */
            float targetOrientation = wanderOrientation + characterOrientation;

            /* Calculate the center of the wander circle */
            Vector3 targetPosition = transform.position + (SteeringBasics.OrientationToVector(characterOrientation) * wanderOffset);

            //debugRing.transform.position = targetPosition;

            /* Calculate the target position */
            targetPosition = targetPosition + (SteeringBasics.OrientationToVector(targetOrientation) * wanderRadius);

            //Debug.DrawLine (transform.position, targetPosition);

            return(steeringBasics.Seek(targetPosition));
        }