using UnityEngine;

namespace ScrambleKit.Hits
{
    [RequireComponent(typeof(Rigidbody2D))]
    public class KnockBackStraight : MonoBehaviour
    {
        private Rigidbody2D rb2;

        void TakeHit(HitInfo hit)
        {
            Vector2 knockForce = rb2.mass * hit.Direction * hit.KnockBackPower;
            rb2.AddForce(knockForce, ForceMode2D.Impulse);
        }

        void Start()
        {
            rb2 = GetComponent<Rigidbody2D>();
        }
    }
}