using GameNetcodeStuff; using UnityEngine; [RequireComponent(typeof(Rigidbody))] public class PhysicsKnockbackOnHit : MonoBehaviour, IHittable { public AudioClip playSFX; public bool Hit(int force, Vector3 hitDirection, PlayerControllerB playerWhoHit = null, bool playHitSFX = false) { if (base.gameObject.GetComponent() == null) { return false; } base.gameObject.GetComponent().AddForce(hitDirection * force * 10f, ForceMode.Impulse); if (playSFX != null && (bool)base.gameObject.GetComponent()) { base.gameObject.GetComponent().PlayOneShot(playSFX); } return true; } }