void Start()
 {
     if (this.tag == "IA")
     {
         cycleIA       = this.GetComponent <VisibilityConeCycleIA>();
         personality   = this.GetComponent <AIPersonality> ();
         objSeenBefore = personality.myMemory.objectsSeenBefore;
     }
     else if (this.tag == "Player")
     {
         cyclePlayer       = this.GetComponent <VisibilityConeCycle>();
         playerPersonality = this.GetComponent <PlayerPersonality>();
     }
     agentPositionControllerScript = this.GetComponent <AgentPositionController>();
 }
Exemple #2
0
    public override SteeringOutput GetSteering()
    {
        if (target != null)
        {
            if (target.GetComponent <AgentPositionController>() == null)
            {
                targetAgent = target.AddComponent <AgentPositionController>();
            }
            //targetAgent = new AgentPositionController();
            else
            {
                targetAgent = target.GetComponent <AgentPositionController>();
            }
            targetAux = target;
            target    = new GameObject();
            Vector2 direction = targetAux.transform.position - transform.position;
            float   distance  = direction.magnitude;
            float   speed     = agent.linearVelocity.magnitude;
            float   prediction;

            if (speed <= distance / maxPrediction)
            {
                prediction = maxPrediction;
            }
            else
            {
                prediction = distance / (speed + 0.001f);
            }
            //Debug.Log("prediction = " + prediction);

            target.transform.position = targetAux.transform.position;

            Vector3 posAux = new Vector3(targetAgent.linearVelocity.x, targetAgent.linearVelocity.y, 0f) + new Vector3(0.001f, 0.001f, 0f);
            target.transform.position += posAux * prediction;


            DestroyImmediate(target);
            target = targetAux;
            return(base.GetSteering());
        }
        return(new SteeringOutput());
    }
 void Start()
 {
     behaviourController = GameObject.FindGameObjectWithTag("GameController").GetComponent <BehaviourAdder>();
     movementScript      = GetComponent <AgentPositionController>();
     objectHandlerPlayer = this.GetComponent <ObjectHandler>();
 }
 public virtual void Awake()
 {
     agent = gameObject.GetComponent <AgentPositionController>();
 }