How do I make bug Character Tilt on slanted terrain?

I’m not super familiar with Unreal but I’ve been working on created a small 3D sidescroller game with a group. The main character is a beetle so the character collision box is a rectangle basically and we don’t use the capsule for collisions.
We’re still struggling to figure out how to make the character rotate on titled terrain without the character glitching in a bunch of different directions.
Any help would be greatly appreciated thank you!

I think a good way to do this would be to run a line trace by channel (connected to event tick) that constantly points downwards, and then breaking that hit, getting the impact normal, and using ‘rotationtoxvector’ to convert that into a rotation, and the set that to the rotation of your mesh

and I can give you more info on how to run the line trace if you need it

We actually have been working with the line trace but it’s super buggy and glitches all over the place. This is the blueprint my team has so far!

How is it bugging out? I noticed you are setting the entire actor rotation instead of just the rotation of a single component, like the mesh. Maybe that has something to do with it.