Пример #1
0
 void Awake()
 {
     inimigoBase         = GetComponent <InimigoBaseScript>();
     rigid               = GetComponent <Rigidbody2D>();
     state               = LixeiraStates.WAITING;
     AttackForceConstant = ThrowHeight * rigid.gravityScale * Physics.gravity.y;
 }
Пример #2
0
 void FixedUpdate()
 {
     if (state == LixeiraStates.ATTACKING)
     {
         TriggerCollider.enabled = false;
         state = LixeiraStates.WAITING;
         Attack();
         Invoke("Cooldown", AttackCooldownTime);
     }
 }
Пример #3
0
    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;
        }
    }