Example #1
0
    public IEnumerator KnockBack(float delay, float force, Vector2 dir)
    {
        KnockingBack = true;
        Rb2D.AddForce(dir * force, ForceMode2D.Impulse);
        yield return(new WaitForSeconds(delay));

        KnockingBack = false;
    }
 public override void FixedUpdateThis()
 {
     base.FixedUpdateThis();
     if (jump)
     {
         Rb2D.AddForce(Vector2.up * JumpPower, ForceMode2D.Impulse);
         jump = false;
     }
 }
Example #3
0
 public override void ReceiveDamage()
 {
     Lives--;
     Rb2D.velocity = Vector3.zero;
     Rb2D.AddForce(transform.up * 3.0F, ForceMode2D.Impulse);
     if (Lives <= 0)
     {
         EventManager.Instance.PostNotification(EVENT_TYPE.UNIT_DIE);
     }
 }
Example #4
0
    private void PhysicsMovement()
    {
        Rb2D.AddForce(transform.right * speed * appliedSprintMultiplier);

        Vector2 targetDir = (rotationTarget - Rb2D.position).normalized;

        if (rotationType == RotationType.RotateTowardsTarget)
        {
            float normalizedDir = Mathf.Sign(Vector2.SignedAngle(transform.right, targetDir));
            Rb2D.AddTorque(normalizedDir * rotationSpeed * appliedSprintMultiplier);
        }
        else if (rotationType == RotationType.RotateTowardsMovement)
        {
            float normalizedDir = Mathf.Sign(Vector2.SignedAngle(transform.right, direction));
            Rb2D.AddTorque(normalizedDir * rotationSpeed * appliedSprintMultiplier);
        }
    }