My custom collision is very buggy. Any help on this?

Okay, so here’s what’s happening:

I’m trying to make a spline-based 2d movement system, similar to games like Klonoa, Pandemonium, and Kirby 64. To do this, I had to override a lot of parts of the default character movement in order to get it to work properly, which included the collision detection.

For collisions, I used a custom function that would detect walls when the character was touching them. This function was hooked up to a branch, so that the character’s distance along the spline wouldn’t update if a wall was detected.

However, whenever I hit certain parts of a wall while jumping with my current setup, the detection glitches out to an almost severe degree. Many times I briefly get stuck in the wall, and if I hit it in the exact right spot, my character will also do things such as jitter around in the ledge before dropping down and then getting stuck in the wall.

Here is my function.

This is just one of the bugs I had encountered with the current implementation.

(It can still happen when I’m not facing the object, it’s just easier to trigger the bug when I’m running into the object))

Upon further inspection (using Draw Debug Type For Duration) I noticed that the sphere trace detection would sometimes rapidly flicker on and off for each frame, and I don’t know why.
I asked this question in /r/unrealengine, and /u/Naojirou was very helpful in explaining what they thought I should do, though I’m having trouble following their directions (you can see my progress in the comment thread). I would like to have more input on this issue, if possible. Thank you.