// Update is called once per frame void Update() { if (off) { return; } timer -= Time.deltaTime; Vector3 dir = target.position - transform.position; dir.z = 0.0f; if (dir != Vector3.zero) { float move = target.position.x > transform.position.x ? 1:-1; enemyFlip.FlipInAttack(move); } if (Vector3.Distance(target.position, transform.position) > 3) { anim.SetWalk(); Vector3 Direction = (target.position - transform.position).normalized; Vector3 NewDirection = new Vector3(Direction.x, 0, 0); transform.position += NewDirection * moveSpeed * Time.deltaTime; } if (Vector3.Distance(target.position, transform.position) < AttackDistance && timer < 0) { anim.SetAttack(); Fire(); } }
void move() { timer += Time.deltaTime; if (anim.IsWalk()) { transform.position = Vector3.Lerp(FromPos, ToPos, timer * SmoothLerp); } if (flip) { flip = false; enemyFlip.FlipInRound(); } if (transform.position == ToPos) { //HastaArreglarAnim = false; anim.SetIdle(); } if (timer >= resetRound) { flip = true; anim.SetWalk(); //HastaArreglarAnim = true; FinalPos = FromPos; FromPos = ToPos; ToPos = FinalPos; timer = 0.0f; } }