Ejemplo n.º 1
0
 private void OnCollisionStay2D(Collision2D collision)
 {
     if (collision.gameObject == Player.Instance.gameObject)
     {
         if (lastHitTime + 1 < Time.time)
         {
             lastHitTime = Time.time;
             playerHealth.Decrease(damage);
             playerRigidbody2D.AddForce(new Vector3(direction * 100, 5), ForceMode2D.Impulse);
         }
     }
 }
Ejemplo n.º 2
0
    private void Update()
    {
        int numberOfBlocks = Mathf.CeilToInt((lastYVelocity * lastYVelocity) / (2 * -rb.gravityScale));

        if (numberOfBlocks >= 4)
        {
            if (Mathf.Abs(rb.velocity.y) < Mathf.Abs(lastYVelocity))
            {
                healthSystem.Decrease(numberOfBlocks - 3);
            }
        }
        lastYVelocity = rb.velocity.y;
    }