Action after being knocked back

Basically im trying to make Undertale Test Place Reborn (UTPR) knockback.
Lord, who made UTPR, gave us information about how to do it using BodyVelocity and Raycast.
Now BodyVelocity’s part is working fine but the problem is Raycast.
It is for detecting next action like sliding on floor or bump into the wall. I dont know how to Raycast it or more specifically i dont know the Direction of it.
If anyone have any solutions please let me know. Thank for your time!