void Chase() { print("Chasing"); if (charType.isSpecial && Random.Range(0, 1) > .95f) { charType.Primary(AngleBetweenVector2(pathfinding.target.position, myTrans.position) + 90f); // Teleport } else if (charType.isRanged && Random.Range(0, 1) > .95f) { charType.Tertiary(AngleBetweenVector2(pathfinding.target.position, myTrans.position) + 90f); // Do a ranged attack } if (Vector2.Distance(pathfinding.target.position, myTrans.position) < attackDistance) { print("I should attack."); state = 2; pathFollower.shouldMove = false; } }
// Update is called once per frame void Update() { cam = GameObject.FindGameObjectWithTag("MainCamera"); cam.transform.SetParent(transform); cam.transform.localPosition = new Vector3(0, 0, -10); if (Input.GetButtonDown("Fire1")) { characterType.Primary(); } else if (Input.GetButtonDown("Fire2")) { characterType.Secondary(); } else if (Input.GetButtonDown("Fire3")) { characterType.Tertiary(); } else if (Input.GetButtonDown("Hypno")) { if (characterType.name != "Hypno") { //StartCoroutine(NoNeutral(2f)); PlayerController np = og.GetComponent <PlayerController>(); np.enabled = true; characterType.rotationTrans.SetActive(false); np.characterType.rotationTrans.SetActive(true); GetComponent <Rigidbody2D>().isKinematic = true; GetComponent <BoxCollider2D>().enabled = false; np.name = name; np.name.text = np.GetComponent <CharacterType>().name; cam.transform.SetParent(og.transform); cam.transform.localPosition = new Vector3(0, 0, -10); characterType.dead = true;//it should kill itself characterType.Die(); // Destroy(this); } else { StartCoroutine(Hypno()); } } UpdateUI(); CheckState(); }