/// <summary> /// Awake is called when the script instance is being loaded. /// </summary> void Awake() { enemy = GetComponent <Enemy>(); sight = GetComponent <EnemySight>(); Nav = GetComponent <NavMeshAgent>(); Nav.speed = enemy.Speed; }
private Transform player; // Reference to the player's transform. public AIBehaviorAggressive(AICharacter character) { enemySight = character.gameObject.GetComponent <EnemySight>(); player = GameObject.FindGameObjectWithTag(Tags.player).transform; playerHealth = player.GetComponent <PlayerHealth>(); lastPlayerSighting = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent <LastPlayerSighting>(); }
void Start() { plyr = GameObject.FindGameObjectWithTag("Player"); agent = GetComponent<NavMeshAgent>(); enemySightSeal = this.GetComponent<EnemySight>(); readInPatrol(startingRoom); }
void Awake() { navAgent = GetComponent <NavMeshAgent>(); anim = GetComponent <Animator>(); sight = GetComponent <EnemySight>(); health = GameObject.FindGameObjectWithTag(Tags.player).GetComponent <PlayerHealth>(); }
void Start() { enemySight = this.GetComponent <EnemySight>(); nav = this.GetComponent <NavMeshAgent>(); player = GameObject.FindGameObjectWithTag(Tags.player).transform; playerHealth = player.GetComponent <PlayerHealth>(); }
public override void Exit() { roboRam.enemyInfo.isMeleeAttacking = false; EnemySight sight = (roboRam.gameObject.GetComponentInChildren <EnemySight>()); sight.GetComponent <BoxCollider2D>().size = new Vector2(sight.originalSightSize, sight.GetComponent <BoxCollider2D>().size.y); }
void Awake() { character = transform; player = GameObject.FindWithTag ("Player").transform; lastPlayerSighting = GameObject.FindGameObjectWithTag(DoneTags.gameController).GetComponent<DoneLastPlayerSighting>(); enemySight = GameObject.FindGameObjectWithTag("AIattack").GetComponent<EnemySight>(); }
// Start is called before the first frame update void Start() { if (Random.Range(0, 2) == 1) { right = true; left = false; } else { left = true; right = false; } dead = false; velocity = new Vector2(); rigidBody = GetComponent <Rigidbody2D>(); spriteRender = GetComponent <SpriteRenderer>(); sight = GetComponentInChildren <EnemySight>(); firstShootTime = shootTime; firstSightTime = sightTime; sceneController = GameObject.Find("SceneController"); player = FindObjectOfType <Player>(); attackBounds = GetComponentInChildren <EnemyAttackBounds>(); anim = GetComponentInChildren <EnemyAnim>(); }
//init vars void Start() { agent = GetComponent <NavMeshAgent>(); selfSight = GetComponent <EnemySight>(); //shopperHas = GetComponent<DetectEnemy>(); player = GameObject.FindGameObjectsWithTag("Player");//player reference playerPos = player[0].transform; lastPlayerSight = playerPos; pathPoints[0] = GameObject.Find("WayPoint1").transform; pathPoints[1] = GameObject.Find("WayPoint2").transform; pathPoints[2] = GameObject.Find("WayPoint3").transform; pathPoints[3] = GameObject.Find("WayPoint4").transform; pathPoints[4] = GameObject.Find("WayPoint5").transform; pathPoints[5] = GameObject.Find("WayPoint6").transform; pathPoints[6] = GameObject.Find("WayPoint7").transform; pathPoints[7] = GameObject.Find("WayPoint8").transform; pathPoints[8] = GameObject.Find("WayPoint9").transform; //init path int randomPoint = Mathf.FloorToInt(Random.Range(0, pathPoints.Length - 1));//pick a random waypoint pathIndex = randomPoint; agent.destination = pathPoints[randomPoint].position;//go to that waypoint }
private AnimatorSetup animSetup; // An instance of the AnimatorSetup helper class. void Awake() { // Setting up the references. //Congiguracion de las referencias. player = GameObject.FindGameObjectWithTag(Tags.player).transform; enemySight = GetComponent <EnemySight>(); nav = GetComponent <NavMeshAgent>(); anim = GetComponent <Animator>(); hash = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent <HashIDs>(); // Making sure the rotation is controlled by Mecanim. //Cerciorarse de que la rotacion es controlada por Mecanin y no por el navmeshagent. nav.updateRotation = false; // Creating an instance of the AnimatorSetup class and calling it's constructor. // Creando una instancia de la Clase AnimatorSetup y llamamos el constructor. animSetup = new AnimatorSetup(anim, hash); // Set the weights for the shooting and gun layers to 1. // Establecemos el peso de las capas Shooting y gun a 1. anim.SetLayerWeight(1, 1f); anim.SetLayerWeight(2, 1f); // We need to convert the angle for the deadzone from degrees to radians. // Necesitamos convertir el angulo de deadzone de grados a radianes, ya que el motor lo opera asi mas facil. deadZone *= Mathf.Deg2Rad; }
// Use this for initialization void Start() { anim = GetComponent <Animator>(); navAgent = this.GetComponent <NavMeshAgent>(); sight = GetComponent <EnemySight>(); move = GetComponent <EnemyMoveAI>(); }
// Use this for initialization void Start() { NavM = GetComponent <NavMeshAgent>(); _isHearing = gameObject.GetComponent <EnemyController>(); _isSpotted = gameObject.GetComponent <EnemySight>(); _target = gameObject.GetComponent <EnemyController>(); }
void Awake() { character = transform; player = GameObject.FindWithTag("Player").transform; lastPlayerSighting = GameObject.FindGameObjectWithTag(DoneTags.gameController).GetComponent <DoneLastPlayerSighting>(); enemySight = GameObject.FindGameObjectWithTag("AIattack").GetComponent <EnemySight>(); }
void Start() { stats = gameObject.GetComponent <EnemyStats>(); sight = gameObject.GetComponent <EnemySight>(); alert = gameObject.GetComponent <EnemyAlert>(); col = gameObject.GetComponent <SphereCollider>(); player = GameObject.FindGameObjectWithTag("Player"); debugRenderer = GetComponentInChildren <Renderer>(); stats.attackRange += GetComponent <CapsuleCollider>().bounds.size.x *0.5f; delaySet = false; collideWithOther = false; delay = stats.IDLE_DELAY; nextWaypt = 0; // 0 - original pos. (whr AI spawns/is from) // Spawn pos if (waypointList.Count > 0) { transform.position = waypointList[nextWaypt].position; transform.rotation = waypointList[nextWaypt].rotation; } // AI render color = green (!alerted) debugRenderer.material.color = Color.green; }
protected void Awake() { _navMeshAgent = GetComponent <NavMeshAgent>(); _animator = GetComponent <Animator>(); _enemySight = GetComponent <EnemySight>(); _patrolPath = transform.parent.Find("Patrol Path")?.GetComponent <PatrolPath>(); StateData = new StateData { Animator = _animator, Npc = gameObject, EnemySight = _enemySight, PatrolPath = _patrolPath, NavMeshAgent = _navMeshAgent, WalkSpeed = walkSpeed, RunSpeed = runSpeed, AccelerationFactor = accelerationFactor, DecelerationFactor = decelerationFactor, DestinationDistanceAccuracy = destinationDistanceAccuracy, IsInDebugMode = debug, IdleAtWaypoint = idleAtWaypoint, MinIdleTime = minIdleTime, MaxIdleTime = maxIdleTime, CheckLastKnownPosition = checkLastKnownPosition }; InitCustomStateMachineData(); }
private Transform player; // Reference to the player's transform. void Awake() { myTransform = transform; enemySight = GetComponent <EnemySight>(); nav = GetComponent <NavMeshAgent>(); player = GameObject.FindGameObjectWithTag("Player").transform; }
void Start() { plyr = GameObject.FindGameObjectWithTag("Player"); agent = GetComponent <NavMeshAgent>(); enemySightSeal = this.GetComponent <EnemySight>(); readInPatrol(startingRoom); }
private void Awake() { m_navAgent = GetComponent <NavMeshAgent>(); m_navAgent.SetDestination(m_WayPoints[0].position); m_EnemySight = GetComponent <EnemySight>(); m_PlayerHealth = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerHealth>(); }
private void Awake() { navMeshAgent = GetComponent <NavMeshAgent>(); enemySight = GetComponent <EnemySight>(); enemyWalk = GetComponent <EnemyWalk>(); animator = spriteObject.GetComponent <Animator>(); }
// void OnCollisionEnter(Collision col) { // if (col.collider.gameObject.isStatic) // { // Destroy(gameObject); // return; // } // else if(col.collider.tag == "Enemy" || col.collider.tag == "Player") // { // if(col.collider.gameObject!=null) { // HP hp = col.collider.gameObject.GetComponent<HP>(); // if (hp != null) { // hp.takeHit(getDamage()); // } // } // Destroy(gameObject); // return; // } // } void OnTriggerEnter(Collider col) { // Dispose object if (col.gameObject.isStatic) { Destroy(gameObject); return; } else if ((col.tag == "Enemy" || col.tag == "Player") && originTag != col.tag) { if (col.gameObject != null) { HP hp = col.gameObject.GetComponent <HP>(); if (hp != null) { hp.takeHit(getDamage()); } if (col.tag == "Enemy") { EnemySight enemySight = col.gameObject.GetComponentInChildren <EnemySight>(); if (enemySight != null) { enemySight.personalLastSighting = originPoint; } } } Destroy(gameObject); return; } }
private Transform player; // Reference to the player's transform. #endregion Fields #region Methods void Awake() { myTransform = transform; enemySight = GetComponent<EnemySight>(); nav = GetComponent<NavMeshAgent>(); player = GameObject.FindGameObjectWithTag("Player").transform; }
void Awake() { enemySight = GetComponent <EnemySight> (); nav = GetComponent <NavMeshAgent> (); player = GameObject.FindGameObjectWithTag("Player").transform; lastSighting = GameObject.FindGameObjectWithTag("GameController").GetComponent <LastPlayerSighting> (); }
// Use this for initialization void Start() { navAgent = this.GetComponent <NavMeshAgent>(); sight = this.GetComponent <EnemySight>(); health = GameObject.FindGameObjectWithTag(Tags.player).GetComponent <PlayerHealth>(); targetPos = wayPoints[index].position; }
// Start is called before the first frame update void Start() { navMeshAgent = GetComponent <UnityEngine.AI.NavMeshAgent>(); enemySight = GetComponent <EnemySight>(); enemyWalk = GetComponent <EnemyWalk>(); enemyState = GetComponent <EnemyState>(); animator = spriteObject.GetComponent <Animator>(); }
private void Awake() { enemySight = GetComponent<EnemySight>(); nav = GetComponent<NavMeshAgent>(); player = GameObject.FindGameObjectWithTag(Tags.player).transform; playerHealth = player.GetComponent<PlayerHealth>(); lastPlayerSighting = GameObject.FindGameObjectWithTag(Tags.gameConstroller).GetComponent<LastPlayerSighting>(); }
// Update is called once per frame void Start() { mSight = GetComponent<EnemySight>(); mBehaviouir = new WonderState(); monkeyAudioSource = GetComponent<AudioSource>(); damage = new MonkeyDamage( this,materialEffect ); }
void Awake() { currentStats = stats; enemySight = transform.GetChild(0).GetComponent <EnemySight>(); agent = GetComponent <NavMeshAgent>(); audioSource = GetComponent <AudioSource>(); animObj.wrapMode = WrapMode.Once; }
// Start is called before the first frame update void Start() { isStuck = false; sight = GetComponent <EnemySight>(); move = GetComponent <guardMovement>(); state = 0; StartCoroutine(isGuardStuck()); }
void Awake() { enemySight = GetComponent <EnemySight> (); nav = GetComponent <NavMeshAgent> (); player = GameObject.FindGameObjectWithTag(Tags.player).transform; playerHealth = player.GetComponent <PlayerHealth> (); lastPlayerSighting = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent <LastPlayerSighting> (); }
[HideInInspector] public bool _aiActive = true; // We will not update a state if the ai is not active // ------------------------------------------------------------------- // METHOD: Awake() // DESCRIPTION: Caches some global variables, and sets the armoured enemies' // default attack range - I vary this with each instance of the // armoured enemy to give them some varience // ------------------------------------------------------------------- protected void Awake() { AnimatorController = GetComponent <Animator>(); NavAgent = GetComponent <NavMeshAgent>(); EnemySightScript = GetComponentInChildren <EnemySight>(); Player = Camera.main.GetComponentInParent <MoveScript>(); // Instead of a manual assign, or using FindObjectOfType, go through the main camera to get the player ref ProjectileAttackRange = Random.Range(5.0f, 15.0f); }
void Awake() { navMeshAgent = GetComponent <UnityEngine.AI.NavMeshAgent>(); enemySight = GetComponent <EnemySight>(); enemyAttack = GetComponent <EnemyAttack>(); animator = spriteObject.GetComponent <Animator>(); stats = GetComponent <Stats>(); }
private void Awake() { enemySight = transform.Find("EnemySight").GetComponent <EnemySight>(); weaponSight = transform.Find("WeaponSight").GetComponent <EnemySight>(); nav = GetComponent <NavMeshAgent>(); animator = GetComponent <Animator>(); player = GameObject.FindGameObjectWithTag("Player"); }
void Awake() { // Setting up the references. enemySight = GetComponent<EnemySight>(); nav = GetComponent<NavMeshAgent>(); playerHealth = GameObject.FindGameObjectWithTag(Tags.player).GetComponent<PlayerHealth>(); lastPlayerSighting = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent<LastPlayerSighting>(); }
void Awake() { character = motor.transform; player = GameObject.FindWithTag("Player").transform; ai = transform.parent.GetComponentInChildren <AI> (); lastPlayerSighting = GameObject.FindGameObjectWithTag("GameController").GetComponent <DoneLastPlayerSighting>(); enemySight = GetComponent <EnemySight>(); }
void Awake() { // Setting up the references. enemyState = EnemyState.IDLE; enemySight = GetComponent<EnemySight>(); nav = GetComponent<NavMeshAgent>(); player = GameObject.Find("Player").GetComponent<Player>(); animator = GetComponentInChildren<Animator>(); }
void Awake() { navAgent = GetComponent <NavMeshAgent>(); navAgent.destination = wayPoints[index].position;//导航的目标位置 navAgent.updatePosition = false; navAgent.updateRotation = false; sight = GetComponent <EnemySight>(); health = GameObject.FindGameObjectWithTag(Tags.player).GetComponent <PlayerHealth>(); }
private int wayPointIndex; // A counter for the way point array. void Awake() { // Setting up the references. enemySight = GetComponent <EnemySight>(); nav = GetComponent <UnityEngine.AI.NavMeshAgent>(); player = GameObject.FindGameObjectWithTag(Tags.player).transform; playerHealth = player.GetComponent <PlayerHealth>(); lastPlayerSighting = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent <LastPlayerSighting>(); }
void Awake() { // Setting up the references. animator = GetComponent<Animator>(); playerMovement = GetComponent<PlayerMovement>(); hash = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent<HashIDs>(); enemy = GameObject.FindGameObjectWithTag (Tags.enemy); secondPlayerCamera = GameObject.FindGameObjectWithTag (Tags.secondPlayerCamera); enemySight = enemy.GetComponent<EnemySight> (); }
private int wayPointIndex; // A counter for the way point array. #endregion Fields #region Methods void Awake() { // Setting up the references. enemySight = GetComponent<EnemySight>(); navMeshAgent = GetComponent<NavMeshAgent>(); player = GameObject.FindGameObjectWithTag(Tags.player).transform; playerHealth = player.GetComponent<PlayerHealth>(); lastPlayerSighting = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent<LastPlayerSighting>(); bulletShooting = GameObject.FindGameObjectsWithTag("EnemyBullet"); }
void Awake() { // Setting up the references. enemySight = GetComponent<EnemySight>(); nav = GetComponent<NavMeshAgent>(); player = GameObject.FindGameObjectWithTag("Player").transform; playerHealth = player.GetComponent<PlayerHealth>(); lastPlayerSighting = GameObject.FindGameObjectWithTag("GameController").GetComponent<LastPlayerSighting>(); positionReset = this.transform.position; }
void Awake () { enemySight = GetComponent<EnemySight>(); playerHealth = player.GetComponent<PlayerHealth>(); nav = GetComponent<NavMeshAgent>(); enemyHealth = GetComponent<EnemyHealth>(); waitTilNextFire = 0; anim = GetComponent<Animator>(); wayPointIndex = roamingWaypoints.Length; firstSighting = true; }
void Awake () { // Setting up the references. enemySight = GetComponent<EnemySight>(); eAnimator = GetComponent<Animator>(); Grid.EventHub.EnemyHit += onEnemyHit; //nav = GetComponent<NavMeshAgent>(); ////players = GameObject.FindGameObjectsWithTag(Tags.Player); //mesh = GetComponentInChildren<MeshRenderer>(); }
private int wayPointIndex; // A counter for the way point array. #endregion Fields #region Methods void Awake() { // Setting up the references. enemySight = GetComponent<EnemySight>(); enemyAnimation = GetComponent<EnemyAnimation>(); nav = GetComponent<NavMeshAgent>(); player = GameObject.Find("N40").transform; playerHealth = player.GetComponent<PlayerHealth>(); lastPlayerSighting = GameObject.Find("gameController").GetComponent<LastPlayerSighting>(); }
void Awake() { enemySight = GetComponent<EnemySight>(); nav = GetComponent<NavMeshAgent>(); lastPlayerSighting = GameObject.FindGameObjectWithTag("GameController").GetComponent<LastPlayerSighting>(); player = GameObject.FindGameObjectWithTag("Player").transform; playerHealth = player.GetComponent<PlayerHealth>(); playerMovement = player.GetComponent<Char_Movement>(); anim = animObj.GetComponent<Animator>(); audio = GetComponent<AudioSource>(); enemAttack = transform.Find("SmackZone").gameObject.GetComponent<EnemyAttack>(); }
void Awake() { character = motor.transform; player = GameObject.FindWithTag ("Player").transform; ai = transform.parent.GetComponentInChildren<AI> (); if (blinkComponents.Length != 0) // FIX HERE changed from 'if (!blinkComponents.Length)' blinkComponents = transform.parent.GetComponentsInChildren<SelfIlluminationBlink> (); lastPlayerSighting = GameObject.FindGameObjectWithTag("GameController").GetComponent<DoneLastPlayerSighting>(); enemySight = GetComponent<EnemySight>(); }
private void Awake() { // Setting up the references. _player = GameObject.FindGameObjectWithTag("Player").transform; _playerScore = _player.GetComponent<PlayerScore>(); _animator = GetComponent<Animator>(); _playerHealth = _player.GetComponent<PlayerHealth>(); enemySight = GetComponent<EnemySight>(); nav = GetComponent<NavMeshAgent>(); lastPlayerSighting = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent<LastPlayerSighting>(); }
private int wayPointIndex; // A counter for the way point array. #endregion Fields #region Methods void Awake() { // Setting up the references. enemySight = GetComponent<EnemySight>(); nav = GetComponent<NavMeshAgent>(); player = player.transform; playerHealth = player.GetComponent<TankLife>(); lastPlayerSighting = GetComponent<LastPlayerSighting> (); enemyHealth = GetComponent<TankLife> (); //canonDirection = GetComponent<rotateEnemyCanon> (); //lastPlayerSighting = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent<LastPlayerSighting>(); //? }
void Awake() { player = GameObject.FindGameObjectWithTag(Tags.player).transform; enemySight = GetComponent<EnemySight>(); navMeshAgent = GetComponent<NavMeshAgent>(); anim = GetComponent<Animator>(); hash = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent<HashIDs>(); navMeshAgent.updateRotation =false; animSetup = new AnimatorSetup(anim, hash); deadZone *= Mathf.Deg2Rad; }
void Awake() { // Setting up the references. enemySight = GetComponent<EnemySight>(); //enemy = GameObject.FindGameObjectWithTag("enemy"); nav = GetComponent<NavMeshAgent>(); player = GameObject.FindGameObjectWithTag("Player").transform; //playerHealth = player.GetComponent<PlayerHealth>(); lastPlayerSighting = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent<LastPlayerSighting>(); myAnimator = GetComponent<Animator>(); Detected = false; running = false; }
private PlayerScore PlayerScore; // for the reference of the playerscore script void Awake() { PlayerScore = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerScore>(); //reference to the playerscore script <<<<<<< HEAD //enemySight = GameObject.FindGameObjectWithTag("Enemy").GetComponent<EnemySight>(); //only works, if there is just one player ======= enemySight = GameObject.FindGameObjectWithTag("Enemy").GetComponent<EnemySight>(); //only works, if there is just one player >>>>>>> dd5711ced731f99b586cb33f83b71c58174c8409 scoreCounter = GameObject.FindGameObjectWithTag("scoreCounter"); //find the scoreCounter gameObject scoreText = scoreCounter.GetComponent<Text>(); //get the Text compnent of that gameobject if (NameOfScene != "StartScreen") //this does not work as I want it to. { Reset(); }//reset it at the start of the level }
void Awake() { navMeshAgent = GetComponent<NavMeshAgent>(); anim = GetComponent<Animator>(); animSetup = new AnimatorSetup(anim, hash); enemySight = GetComponent<EnemySight>(); enemyHealth = GetComponent<EnemyHealth>(); player = GameObject.FindGameObjectWithTag("Player").transform; //INITIALIZING THE PATROLLING currentWaypointIndex = 0; navMeshAgent.destination = waypoints[currentWaypointIndex].position; anim.SetFloat("Speed", patrollingSpeed * patrolSpeedRatio); navMeshAgent.speed = patrollingSpeed; previousNavMeshDestination = Vector3.zero; }
protected override void Awake() { base.Awake(); // Setting up the references. enemySight = GetComponent<EnemySight>(); nav = GetComponent<NavMeshAgent>(); player = (PlayerController)FindObjectOfType(System.Type.GetType("PlayerController")); shooting = false; waysNetwork = null; patrolWayPoints = new Vector3[0]; // Animations hashIDs = GetComponent<EnemyHashIDs>(); anim = GetComponentInChildren<Animator>(); anim.SetLayerWeight(0,1f); }
void Awake() { player = GameObject.FindGameObjectWithTag(Tags.player).transform; enemySight = GetComponent<EnemySight>(); nav = GetComponent<NavMeshAgent>(); anim = GetComponent<Animator>(); hash = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent<HashIDs>(); nav.updateRotation = false; //To make sure that the rotation of the enemy is set by the animator and not by the nav mesh agent - To reduce foot slipping whilst turning corners animSetup = new AnimatorSetup(anim, hash); anim.SetLayerWeight(1, 1f); //Shooting Layer anim.SetLayerWeight(2, 1f); //Gun Layer deadZone *= Mathf.Deg2Rad; //Convert from degrees to radians }
void Awake() { //referencing scripts player = GameObject.FindGameObjectWithTag("Player").transform; enemySight = GetComponent<EnemySight>(); nav = GetComponent<NavMeshAgent>(); anim = GetComponent<Animator>(); hash = GameObject.FindGameObjectWithTag("gameController").GetComponent<HashIDs>(); EnemyAI = GetComponent<enemyAI>(); <<<<<<< HEAD nav.updateRotation = false; //make sure the rotation is controlled by mecanim animSetup = new AnimatorSetup(anim, hash); //creating an instance of the AnimatorSetu class and calling it´s constructor deadZone += Mathf.Deg2Rad; //convert the angle for the deadzone from degrees to radiants ======= nav.updateRotation = false; //make sure the rotation is controlled by mecanim animSetup = new AnimatorSetup(anim, hash); //creating an instance of the AnimatorSetu class and calling it´s constructor deadZone += Mathf.Deg2Rad; //convert the angle for the deadzone from degrees to radiants >>>>>>> dd5711ced731f99b586cb33f83b71c58174c8409 }
private Transform player; // Reference to the player's transform. #endregion Fields #region Methods void Awake() { // Setting up the references. player = GameObject.Find("N40").transform; enemySight = GetComponent<EnemySight>(); nav = GetComponent<NavMeshAgent>(); anim = GetComponent<Animator>(); // Making sure the rotation is controlled by Mecanim. nav.updateRotation = false; // Creating an instance of the AnimatorSetup class and calling it's constructor. animSetup = new AnimatorSetup(anim); // Set the weights for the shooting and gun layers to 1. anim.SetLayerWeight(1, 1f); anim.SetLayerWeight(2, 1f); // We need to convert the angle for the deadzone from degrees to radians. deadZone *= Mathf.Deg2Rad; }
public void handleView( EnemyMachine controller, EnemySight mSight ) { //need initial escape destination. if( !fire ){ SoundManager.Instance.playIndieSingle( controller.monkeyAudioSource, controller.monkeyAudioClips[1] ); controller.doAgentMove(); fire = true; } else{ //caculate if destiniation need regenerate. float distanceToDest = Vector3.Distance( controller.transform.position, oldTarget); if( distanceToDest < 1f ){ controller.doAgentMove(); } } if( !mSight.enemyView.PlayerAround && mSight.enemyView.leaveTime > 0){ if(Mathf.FloorToInt(Time.time) - mSight.enemyView.leaveTime > 3 ) controller.mBehaviouir = new SuspiciousState( oldTarget ); } //Debug.Log("State : EscapeState"); }
// Update is called once per frame void Update() { // set walking boolean for OnAnimatorMove function if (navMesh.hasPath) { walking = true; } else { walking = false; } //Check sight component to refresh state of playerInSight and alert status vision = gameObject.GetComponent<EnemySight> (); // Movement Decision tree // if not alerted, patrol if (vision.alerted == false){ Patrol(); //speechbubble.SetActive(false); } else { // if alerted and player is visibile, attack if(vision.playerInSight){ //if player is in sight, attack //speechbubble.SetActive(true); anim.SetBool("InSight", true); Attack (); } // if alerted and player is not visible, search last known location else{ // if player is not in sight (but guard is alarmed), chase and search anim.SetBool("InSight", false); Search (); } } }
void Awake() { character = motor.transform; player = GameObject.FindWithTag ("Player").transform; ai = transform.parent.GetComponentInChildren<AI> (); lastPlayerSighting = GameObject.FindGameObjectWithTag("GameController").GetComponent<DoneLastPlayerSighting>(); enemySight = GetComponent<EnemySight>(); }
void Start() { // Cache references to other scripts/components vision = gameObject.GetComponent<EnemySight> (); anim = GetComponent<Animator> (); alertAI = GetComponent<GuardAI> (); navMesh = gameObject.GetComponent<NavMeshAgent>(); player = GameObject.FindWithTag ("Player"); // initialise starting patrol points to 0 index nextIndex = 0; alertIndex = 0; // Compile array of waypoints for guard to patrol patrolRoute = new Vector3[4] { point1.transform.position, point2.transform.position, point3.transform.position, point2.transform.position }; // Ditto, for the extra points to patrols when alerted alertRoute = new Vector3[4]{ A_point1.transform.position, A_point2.transform.position, A_point3.transform.position, A_point2.transform.position, //point1.transform.position, //point2.transform.position, //point3.transform.position }; // start patrolling at walking speed navMesh.SetDestination (patrolRoute[nextIndex]); anim.SetFloat ("Speed", 1.0f); }
// Use this for initialization void Start() { //Field of View Script / Player Detection enemySight = GetComponent<EnemySight>(); //Nav Mesh agent sets up the mesh that our characters can move on. nav = GetComponent<NavMeshAgent>(); //autobraking causes the character to pause before each waypoint nav.autoBraking = false; //char references player = GameObject.Find("Player"); enemy = GameObject.Find("Enemy"); //Set the first waypoint wayPointIndex = 0; //Get the list of waypoint objects. wayPoints = GameObject.FindGameObjectsWithTag("CyclopsWaypoint"); }