How do I adjust a SkeletalMesh's rotation to accommodate slopes in my level?

Similar to foot placement IK, I want to adjust my character’s SkeletalMeshComponent so it looks better when it’s standing on a slope, however it doesn’t need to be complicated, as the mesh has no legs/feet/other extremities.

So say I’ve got a cube for my player, how would I rotate the cube to match the slope’s angle?

Preferably a Blueprint solution :wink:

one possible solution:

get the pawn(cube)location and rotation.
send a trace from the pawn and return the Normal of the ground plane(or whatever has been hit)
rotate your pawn(cube) to the normal rotation.
youll want to use vInterp node to make it a smooth transition.

blueprints have nodes for all of that.

That’s great! I’ve just now been able to come up with a very similar solution as well, though it’s probably not very elegant in terms of Blueprint readability :slight_smile:

I’ll post an answer with my current solution

  • Here’s how it could be done, though this doesn’t work correctly!

  • And here’s how I have it now, thanks to some experimenting with Nathan’s solution!