// Update is called once per frame void LateUpdate() { if (!gotIt) { Collider2D[] hits = Physics2D.OverlapCircleAll(transform.position, range1); foreach (Collider2D h in hits) { if (h.gameObject == target) { gotIt = true; break; } } } if (target == null) { target = GameObject.FindGameObjectWithTag("Player"); } //hadi bash ytba3ni 3adow ila kont kanshof fih if (gotIt) { if (folowNow == true) { //if (Vector3.Dot (target.transform.position - transform.position, target.transform.localScale.x * Vector3.right)< 0) transform.position = Vector3.MoveTowards(transform.position, target.transform.position + distance_between, ratio); } } float distanceX = transform.position.x - target.transform.position.x; float distanceY = transform.position.y - target.transform.position.y; //hadi bash hta yt9abl m3aya 3ad ytiri3lia if (distanceY == 0 && iamIlive == true) { shoot_now.shotnow(); } Flip(distanceX); Debug.Log(distanceY); }
void FixedUpdate() { if (player_Standing == true) { isGrounded = Physics2D.OverlapCircle(groundcode.position, groundradius, theground); // hadi bash ytba3ni 3adow ila kan masafa li binatna != distance if (player_Standing == true && distance != distance_between.x && iam_die == false) { anim.SetInteger("animstate", 1); } else if (player_Standing == true && distance == distance_between.x && iam_die == false) { anim.SetInteger("animstate", 0); if (timer > time_toshot) { enmy_shot.shotnow(); } timer = 0; } } }