Have two animations, one where the body falls backwards, the other where the body falls forwards. When the character dies, do a trace in the default direction the body is falling (appears to be forwards in the picture you’ve posted). If an object is detected, play the other animation.
You might need even more than two animations, because the above proposed solution wouldn’t work if the character dies between two walls. Then you’d need left/right animations as well. One of the four ought to cover it.