Method to align a 2D decal with the angle of a flat surface?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Tato64

Hey gang, im working on the “blood and gore” part of my 2D shooter, but i come to you with a doubt regarding a “How would i do this?” because honestly i have no idea where to start.

Some context first: When you shoot (using raycasts) an enemy (the game is top down 2D, btw) a bunch of things happen, some CPUParticles that spray blood around, some decals on the ground where those particles would “land”, a pool of blood forms after a while, etc. but here’s the thing regarding the question:

When the raycast hits, it spawns another raycast that “continues” the path of the original one. This new raycast only collides with walls (staticbodies in a certain collision layer) and has a fixed length, if it doesnt hit anything, then nothing happens, BUT if it hits a wall it will leave a “blood splat” decal (Basically just a sprite) there.

My problem is, since this is top down, the bloodsplat sprite would have a “flat side” cutting through the middle of the sprite, and it would need to be rotated to “line up” with the flat side of the wall… How would i do this?

The methods i thought dont work or are too complex, there must be a simple way i dont know about!

Thanks in advance for any help!

EDIT: I just realized i could use like… “regular blood splat” decals and have that graphic only appear “over” walls but “below” everything else. This seems like the simplest solution… I’d still wouldnt know how to do it.