IEnumerator Stomp() { GameObject boss = transform.root.gameObject; //temporary animation thingy float scale = 7f; boss.GetComponent <Transform>().localScale = new Vector3(scale, scale, 1f); // Wait for animation to finish yield return(new WaitForSeconds(stompLength)); //if distance to player still in range, push them back playerTransform = playerPos.GetComponentInChildren <playerShooting>().transform; float distance = Vector3.Distance(playerTransform.position, this.transform.root.position); //Deal damage to player if (playerHealth != null) { playerHealth.Damage(stompDamage); } //Push player back if they're still in range && the attack hasn't already ended if (distance <= stompDistance && attackIsActive) { GameObject player = playerPos.transform.root.gameObject; Vector2 playerPosition = new Vector3(player.transform.position.x, player.transform.position.y); Vector3 dirBackwards = playerPosition - (Vector2)transform.position; //boss vector3 + player vector3 playerPos.AddForce(dirBackwards.normalized * stompForce); } //reset boss state boss.GetComponent <BossEnemy>().stomping = false; //reset boss scale boss.GetComponent <Transform>().localScale = new Vector3(5f, 5f, 5f); attackIsActive = false; }