I want to rotate a static mesh away from the player character to simulate trampling of tall grass.

To make the grass “lie down” away from the player would be relatively easy by just facing the player with the Z-axis and then lie it down 90 degrees in X or Y, but that would make the grass turn, which would be really weird.

So I’d need to calculate the rotation only in X and Y, and my math skills are not quite up to the challenge. Any math wiz who might be able to point me in the right direction would be greatly appreciated.

I calculated a simple but most likely very redundant manual solution using LookAtRotation and then manually setting the X and Y rotation depending on whether LookAtRotation’s Yaw is between 0 and 90, -90 and 0, -180 and -90 or 90 and 180.

This results in four big conditional checks each for X and Y, and I’m sure there is some vectormath that could calculate both in a much more efficient way.

At least it works as intended for now, but I’d appreciate learning a more proper way of doing it.

This is the result; four bushes lying down away from the ball after rolling over them from different directions.

This is the chunky manual calculation of just the Y rotation.