Example #1
0
 public AIObjectAvoid(AIState state, Transform obj, float weight, AISeek seek)
 {
     trans       = obj;
     seeker      = seek;
     this.State  = state;
     this.Weight = weight;
 }
Example #2
0
    // Use this for initialization
    void Awake()
    {
        //Initialize state
        state = new AIState();
        state.MaxLinearAcceleration  = 5f;
        state.AngularVelocity        = 0f;
        state.MaxAngularAcceleration = 10f;
        state.MaxLinearVelocity      = new Vector3(5f, 0, 5f);
        state.MaxAngularVelocity     = 10f;
        state.LinearVelocity         = state.MaxLinearVelocity.magnitude * this.transform.forward;
        if (target != null)
        {
            Vector3 temp = target.position;
            temp.y       = 0;
            state.Target = temp;
        }
        else
        {
            state.Target = Vector3.zero;
        }

        //Reference animator
        animator = this.GetComponent <Animator>();
        //Mandatory Behaviours
        behaviours = new List <AIBehaviour>();

        AISeek seek = new AISeek(state, this.transform, 1f);

        behaviours.Add(seek);
        rayAvoid = new AIObjectAvoid(state, this.transform, 10f, seek);
        behaviours.Add(rayAvoid);
        behaviours.Add(new AIAlign(state, this.transform, 1f));
        separation = new AISeparate(state, this.transform, .3f);
        behaviours.Add(separation);
        avoid = new AICollisionAvoid(state, this.transform, 3f);
        behaviours.Add(avoid);

        if (BehaviourSetting == AIBehaviourType.ReachGoal)
        {
            behaviours.Add(new AIArrive(state, this.transform, .4f));
        }
        else if (BehaviourSetting == AIBehaviourType.Wander)
        {
            behaviours.Add(new AIWander(state, this.transform, .1f));
        }
    }
Example #3
0
    // Use this for initialization
    void Start()
    {
        seek       = gameObject.AddComponent <AISeek>() as AISeek;
        align      = gameObject.AddComponent <AIAlign>() as AIAlign;
        wander     = gameObject.AddComponent <AIWander>() as AIWander;
        separation = gameObject.AddComponent <AISeparation>() as AISeparation;

        separation.threshold       = 2.0f;
        separation.maxAcceleration = 20;

        seek.maxSpeed = Random.Range(7, 10);

        entities = new ArrayList();
        foreach (Transform t in GameObject.FindObjectsOfType(typeof(Transform)))
        {
            if (t.name == "Entity" && t != transform)
            {
                entities.Add(t);
            }
        }
    }
Example #4
0
	// Use this for initialization
	void Awake () {
		//Initialize state
		state = new AIState();
     	state.MaxLinearAcceleration = 5f;
		state.AngularVelocity = 0f;
		state.MaxAngularAcceleration = 10f;
		state.MaxLinearVelocity = new Vector3(5f, 0, 5f);
		state.MaxAngularVelocity = 10f;
		state.LinearVelocity = state.MaxLinearVelocity.magnitude * this.transform.forward;
		if(target != null){
		    Vector3 temp = target.position;
		    temp.y = 0;
		    state.Target = temp;
		}
		else
			state.Target = Vector3.zero;

		//Reference animator
		animator = this.GetComponent<Animator>();
		//Mandatory Behaviours
		behaviours = new List<AIBehaviour>();

		AISeek seek = new AISeek(state, this.transform, 1f);
		behaviours.Add (seek);
		rayAvoid = new AIObjectAvoid(state, this.transform, 10f, seek);
		behaviours.Add (rayAvoid);
		behaviours.Add (new AIAlign(state, this.transform, 1f));
		separation = new AISeparate(state, this.transform, .3f);
		behaviours.Add (separation);
		avoid = new AICollisionAvoid(state, this.transform, 3f);
		behaviours.Add (avoid);

        if(BehaviourSetting == AIBehaviourType.ReachGoal)
			behaviours.Add (new AIArrive(state, this.transform, .4f));
		else if(BehaviourSetting == AIBehaviourType.Wander)
			behaviours.Add (new AIWander(state, this.transform, .1f));
	}
Example #5
0
	public AIObjectAvoid(AIState state, Transform obj, float weight, AISeek seek){
		trans = obj;
		seeker = seek;
		this.State = state;
		this.Weight = weight;
	}