// Use this for initialization void Start() { audioSource = GetComponent <AudioSource>(); startPlatform.calculaReachables(); transform.position = startPlatform.transform.position + offset; if (attackdir == 1) { attackPlatform = startPlatform.topPlat; transform.LookAt(startPlatform.transform.position + Vector3.left); } if (attackdir == 2) { attackPlatform = startPlatform.rightPlat; transform.LookAt(startPlatform.transform.position + Vector3.forward); } if (attackdir == 3) { attackPlatform = startPlatform.bottomPlat; transform.LookAt(startPlatform.transform.position + Vector3.right); } if (attackdir == 4) { attackPlatform = startPlatform.leftPlat; transform.LookAt(startPlatform.transform.position + Vector3.back); } //transform.LookAt(attackPlatform.transform); startPlatform.entity = this.gameObject; mAnimator = GetComponent <Animator>(); agent = GetComponent <NavMeshAgent>(); aura = transform.Find("auraEnemy").gameObject; aura.SetActive(false); }
// Update is called once per frame void Update() { if (transform.position != newPosition) { float distanceCovered = (Time.time - transformStartTime) * 2.0F; float amountOfJourneyCompleted = distanceCovered / journeyLength; transform.position = Vector3.Lerp(transform.position, newPosition, amountOfJourneyCompleted); if (plat.entity != null) { plat.entity.transform.position = Vector3.Lerp(plat.entity.transform.position, newPosition, amountOfJourneyCompleted); } if (plat.topPlat != null) { plat.topPlat.calculaReachables(); } if (plat.bottomPlat != null) { plat.bottomPlat.calculaReachables(); } if (plat.leftPlat != null) { plat.leftPlat.calculaReachables(); } if (plat.rightPlat != null) { plat.rightPlat.calculaReachables(); } plat.calculaReachables(); if (plat.topPlat != null) { plat.topPlat.calculaReachables(); } if (plat.bottomPlat != null) { plat.bottomPlat.calculaReachables(); } if (plat.leftPlat != null) { plat.leftPlat.calculaReachables(); } if (plat.rightPlat != null) { plat.rightPlat.calculaReachables(); } } }