// Use this for initialization public virtual void Start() { AddType(EntityType.Entity); dead = false; pathRequested = false; isOnPath = false; health = startingHealth; medKits = 0; seenMedKits = new Dictionary <string, Vector3>(); blackboard = new Blackboard(); blackboard.treeData.Add("entity", this); col = transform.GetComponentInChildren <SphereCollider>(); grid = GameObject.Find("GameController").GetComponent <Grid>(); eyes = GetComponentInChildren <AISight>(); enemiesInLevel = new List <GameObject>(); foreach (Entity entity in GameController.gameController.entitiesInLevel) //Check entities in the level against this AI's enemy type { if (((1 << entity.gameObject.layer) & enemiesMask) != 0) { enemiesInLevel.Add(entity.gameObject); } } }
// Use this for initialization void Start() { aiUnit_ = this.GetComponent <AIUnit>(); aiSight_ = aiSight_.GetComponent <AISight>(); subState = SubState.Empty; }
//init vars void Start() { agent = GetComponent <NavMeshAgent>(); selfSight = GetComponent <AISight>(); player = GameObject.FindGameObjectsWithTag("Player");//player reference playerPos = player[0].transform; lastPlayerSight = playerPos; }
/**************************************************************************** * Unity Methods ****************************************************************************/ /**************************************************************************** * Awake */ /** ****************************************************************************/ protected virtual void Awake() { /** Make sure the tank can see. */ if (aiSight == null) { aiSight = gameObject.GetComponent <AISight>(); } /** Set Layer Mask. */ mLayerMask = 1 << LayerMask.NameToLayer("Interractive"); }
// Use this for initialization void Start() { aiUnit_ = this.GetComponent <AIUnit>(); aiSight_ = aiSight_.GetComponent <AISight>(); retreating_ = false; //Get Path to Flag aiUnit_.getNewPath(aiUnit_.startNode, aiUnit_.targetNode); subState = SubState.Capturing; }
void Awake() { nav = GetComponent <UnityEngine.AI.NavMeshAgent> (); aiSight = GetComponent <AISight> (); globalLastPlayerSighting = GameObject.FindGameObjectWithTag("GameController").GetComponent <GlobalLastPlayerSighting> (); if (team == "Team0") { enemyTeam = "Team1"; } else { enemyTeam = "Team0"; } //enemyTeamMembers = GameObject.FindGameObjectsWithTag("GameController"). }
private void Awake() { // get the components on the object we need ( should not be null due to require component so no need to check ) agent = GetComponentInChildren <NavMeshAgent>(); character = GetComponent <ThirdPersonCharacter>(); player = FindObjectOfType <ThirdPersonUserControl>(); _aiSight = GetComponentInChildren <AISight>(); _noiseScript = GameObject.FindGameObjectWithTag("NoiseBar").GetComponent <Noise>(); var mechanicsObj = GameObject.FindWithTag("MechanicsObject"); micInput = mechanicsObj.GetComponent <MicrophoneInput>(); _hideFromWitchCooldownTarget = mechanicsObj.GetComponent <WitchKeepStill>().keepStillDuration; _witchScript = mechanicsObj.GetComponent <WitchKeepStill>(); _aiSight.aiController = this; }
// Use this for initialization public override void Awake() { base.Awake(); target = GameObject.FindGameObjectWithTag("Player"); _platformMask = SetMask(); targetRb2d = target.GetComponent <Rigidbody2D>(); _startingPos = transform.position; _amps_sound = GetComponent <AudioSource>(); _lastAttackTime = 0; _attackAniDuration = 0; _lastHitTime = 0; _lastPatrolTime = 0; waiting = false; var movement = new Vector2(-1 * acceleration * rb2d.mass, 0); rb2d.AddForce(movement, ForceMode2D.Force); patrolPointMin = new Vector2(this.transform.position.x - patrolDistance, this.transform.position.y); patrolPointMax = new Vector2(this.transform.position.x + patrolDistance, this.transform.position.y); _buddyMask = LayerMask.GetMask("Enemy"); _sight = new AISight(gameObject.GetComponentInChildren <CapsuleCollider2D>(), sightRange); }
void OnSceneGUI() { AISight ai_sight = (AISight)target; Handles.color = Color.white; Handles.DrawWireArc(ai_sight.transform.position, Vector3.up, Vector3.forward, 360, ai_sight.view_radius); Vector3 view_angle_a = ai_sight.DirectionFromAngle(-ai_sight.view_angle / 2, false); Vector3 view_angle_b = ai_sight.DirectionFromAngle(ai_sight.view_angle / 2, false); Handles.DrawLine(ai_sight.transform.position, ai_sight.transform.position + view_angle_a * ai_sight.view_radius); Handles.DrawLine(ai_sight.transform.position, ai_sight.transform.position + view_angle_b * ai_sight.view_radius); Handles.color = Color.red; foreach (GameObject visible_target in ai_sight.visible_targets) { Handles.DrawLine(ai_sight.transform.position, visible_target.transform.position); } Handles.color = Color.green; foreach (Transform visible_cover_pos in ai_sight.visible_cover_positions) { Handles.DrawLine(ai_sight.transform.position, visible_cover_pos.position); } }
public override void Init(Blackboard blackboard) { this.blackboard = blackboard; eyes = blackboard.GetValueFromKey <AISight>("eyes"); entity = eyes.transform.parent.GetComponent <Entity>(); }
public override void Init(Blackboard blackboard) { this.blackboard = blackboard; companion = blackboard.GetValueFromKey <Companion>("companion"); eyes = companion.GetComponentInChildren <AISight>(); }
public override void Init(Blackboard blackboard) { this.blackboard = blackboard; entity = blackboard.GetValueFromKey <Entity>("entity"); eyes = entity.GetComponentInChildren <AISight>(); }