using UnityEngine; using UnityEngine.InputSystem; public static class Utils { public static bool WasPressedThisFrame(this InputAction.CallbackContext ctx, ref bool lastValue) { bool newValue = ctx.ReadValueAsButton(); bool wasJustPressed = !lastValue && newValue; lastValue = newValue; return wasJustPressed; } public static void SetEnabled(this Rigidbody2D rb, bool enabled) { rb.velocity = Vector2.zero; rb.angularVelocity = 0f; rb.isKinematic = !enabled; } }