void OnTriggerStay(Collider other) { if (other.gameObject.GetComponent <GuardPatrol>()) { enemy = other.gameObject.GetComponent <GuardPatrol>(); } }
void OnTriggerExit(Collider other) { if (other.gameObject.GetComponent <GuardPatrol>()) { enemy = null; } }
// Use this for initialization void Start() { //waitBeforePatrolResumes = 1.0f; agent = gameObject.GetComponent <NavMeshAgent>(); fov = gameObject.GetComponent <FieldOfView>(); gpat = gameObject.GetComponent <GuardPatrol>(); gpat2 = gameObject.GetComponent <GuardPatrolv2>(); playerObject = GameObject.FindGameObjectWithTag("Player"); gC = GameObject.FindGameObjectWithTag("GameController"); caughtPlayer = false; guardState = 1; patFire = 0; fovEnumerator = fovLerpChange(1.0f); alarmCalledBy = null; hidingSpotWaitTime = 1.75f; startSecondLook = false; soundTargetSet = false; platePrefab = GameObject.Find("GoldenPlateSafety"); gobletPrefab = GameObject.Find("GoldenGobletSafety"); }
public override void OnStateEnter() { base.OnStateEnter(); GuardPatrol patrol = context.PatrolRoute; waypoints = patrol != null?patrol.GetWaypoints() : new Waypoint[0]; waypointIndex = context.LastWaypointIndex; navMeshAgent = context.GetComponent <NavMeshAgent>(); }
void OnTriggerEnter(Collider other) { //print (other.tag); if (other.tag.Equals("Guard")) { GuardPatrol gp = other.GetComponent <GuardPatrol> (); if (gp != null) { gp.waypointReached(this); } } }
void InitializeRanger() { pathingScript = gameObject.GetComponent <GuardPatrol>(); rb = gameObject.GetComponent <Rigidbody2D>(); spriteComponent = gameObject.GetComponent <SpriteRenderer>(); players = GameObject.FindGameObjectsWithTag("Player"); playerOne = players[0]; playerTwo = players[1]; agent = gameObject.GetComponent <NavMeshAgent>(); agent.updateRotation = false; agent.updateUpAxis = false; agent.Warp(transform.position); agent.SetDestination(gameObject.GetComponent <GuardPatrol>().currentCheckpoint.transform.position); agent.speed = chaseSpeed; }
public Task <GuardPatrol> FindNearestPatrol(GeoCoordinates targetLocation, IEnumerable <GuardPatrol> patrols) { GuardPatrol result = patrols.FirstOrDefault(); double minDistanceInMeters = result.GeoLocation.DistanceToInMeters(targetLocation); foreach (var guardPatrol in patrols) { var currentDistanceToTargetInMeters = guardPatrol.GeoLocation.DistanceToInMeters(targetLocation); if (currentDistanceToTargetInMeters < minDistanceInMeters) { result = guardPatrol; minDistanceInMeters = currentDistanceToTargetInMeters; } } return(Task.FromResult(result)); }
//************************************************** // Player Input Commands //************************* public void OnSlash(InputAction.CallbackContext context) { if (context.started && !isDead) { m_Animator.SetTrigger("Slash"); runningAnimation = 4; isAttacking = true; timeRemaining = 0.4f; timerIsRunning = true; // TODO set forward collider trigger as active enemy = damageArc.getEnemy(); if (enemy) { enemy.setDamage(damage); } } }
void OnTriggerStay(Collider other) { //print (other.tag); if (other.tag.Equals("Fox")) { RaycastHit hit = new RaycastHit(); Physics.Linecast(transform.parent.position, other.transform.position, out hit); if (hit.collider.tag.Equals("Fox")) { //print (other.transform.position); if (Time.realtimeSinceStartup > lastTime + cd) { lastTime = Time.realtimeSinceStartup; GameObject gameObject = (GameObject)Instantiate(g, other.transform.position, other.transform.rotation); gameObject.SetActive(true); GuardPatrol patrol = GetComponentInParent <GuardPatrol> (); patrol.setVisionPoint(gameObject.GetComponent <VisionPoint> ()); } } /*Destroy(other.gameObject);*/ } }
private void Start() { col = GetComponent <SphereCollider>(); gp = GetComponent <GuardPatrol>(); gi = GetComponent <GuardInvestigate>(); }
// Use this for initialization void Start() { guard = GetComponentInParent <GuardPatrol> (); }