Exemple #1
0
    public override Vector3 Steer(AISteeringController controller)
    {
        //calculate the estimated position of our target
        // - add its velocity to its position
        Vector3 estimatedPosition = target.velocity + target.transform.position;

        //calculate a directional vector from your position toward the estimated position
        return((controller.transform.position - estimatedPosition).normalized /*normalize to get direction*/ * controller.maxSpeed);//scale the directional vector by our maximum speed
    }
Exemple #2
0
    public override Vector3 Steer(AISteeringController controller)
    {
        Vector3 offset = Random.onUnitSphere * allowedRadius;

        offset.y = 0.0f;
        offset  += controller.transform.forward * distance;
        Vector3 offsetPosition = controller.transform.position + offset;

        return((offsetPosition - controller.transform.position).normalized * controller.maxSpeed);
    }
Exemple #3
0
        public override Vector3 Steer(AISteeringController controller)
        {
            if (timer >= timeToMove)
            {
                var randomTarget = (Random.insideUnitSphere * 100) + target.position;
                randomTarget.y = 0;

                timer = 0.0f;

                return(randomTarget);
            }
            else
            {
                return(Vector3.zero);
            }
        }
Exemple #4
0
    public override Vector3 Steer(AISteeringController controller)//override to return the difference between the target position instead of the default zero
    {
        //start with a random target on the edge of the sphere with a set radius around the agent
        //You can add Random.onUnitSphere to the agent's position
        //Random.onUnitSphere generates a random point on a sphere -- to have it work with different radii, scale the random value by your radius
        Vector3 offset = Random.onUnitSphere * radius;        //sets values to random

        offset.y = 0.0f;                                      //sets y to zero so that only x and z changes
        offset  += controller.transform.forward * distance;
        Debug.DrawRay(controller.transform.position, offset); //visually shows the wander function working

        Vector3 randomTargetAroundAgent = controller.transform.position /*gets position of agent*/ + offset /*creates a random sphere radius*/ * radius /*max radius of sphere*/;

        //add a randomised vector to the target, with a magnitude specified by a jitter amount


        //bring the target back to the radius of the sphere by normalising it and scaling by the radius
        return((randomTargetAroundAgent - controller.transform.position).normalized * controller.maxSpeed /*radius*/);

        //add the agents heading, multiplied by a distance to the target
    }
Exemple #5
0
 public override Vector3 Steer(AISteeringController controller)
 {
     return(base.Steer(controller));
 }
Exemple #6
0
 public override Vector3 Steer(AISteeringController controller)
 {
     return((target.position + controller.transform.position).normalized * controller.maxSpeed);
 }
Exemple #7
0
 public virtual Vector3 Steer(AISteeringController controller)
 {
     return(Vector3.zero);
 }
Exemple #8
0
 public virtual Vector3 Steer(AISteeringController controller)
 {
     return(Vector3.zero);    // defaults to zero, because if an entity isn't affected by a behavior, they should not move
 }
Exemple #9
0
 public override Vector3 Steer(AISteeringController controller, float fleeSeekDist)
 {
     return((controller.transform.position - target.position).normalized * controller.maxSpeed);
 }
Exemple #10
0
 public virtual Vector3 Steer(AISteeringController controller, float fleeSeekDist)
 {
     return(Vector3.zero);
 }
Exemple #11
0
 public Transform target;                                                                                                       //set a target to go towards
 public override Vector3 Steer(AISteeringController controller)                                                                 //override to return the difference between the target position instead of the default zero
 {
     return((target.position - controller.transform.position).normalized /*normalize to get direction*/ * controller.maxSpeed); //multiply it by max speed
 }
Exemple #12
0
 public virtual Vector3 Steer(AISteeringController controller)
 {
     return(Vector3.zero);//default will return zero
 }