void Awake() { inimigoBase = GetComponent <InimigoBaseScript>(); rigid = GetComponent <Rigidbody2D>(); state = LixeiraStates.WAITING; AttackForceConstant = ThrowHeight * rigid.gravityScale * Physics.gravity.y; }
void FixedUpdate() { if (state == LixeiraStates.ATTACKING) { TriggerCollider.enabled = false; state = LixeiraStates.WAITING; Attack(); Invoke("Cooldown", AttackCooldownTime); } }
void OnTriggerStay2D(Collider2D other) { if (other.CompareTag("Player")) { TriggerCollider.enabled = false; // Lock on player var distance = other.transform.position.x - transform.position.x; AttackDirection = new Vector2( distance, ThrowHeight ).normalized; AttackForce = Mathf.Abs(AttackForceConstant * distance); state = LixeiraStates.ATTACKING; } }