I’m trying to make an object rotate in the same direction relative to the direction the camera is looking. With what I have so far the rotations are correct at 0,90,180,270 degrees but every point in between up to 45 degrees, the rotation gets thrown off and starts rotating diagonally. What I’m hoping is that this is just a simple math problem that I’m overlooking. Thanks in advance!
I’d suggest trying to following approach to start with and see if it fits your needs…
in Begin Play > Get Player Controller > Get Player Camera Manager > Get Camera (store a reference to this camera this as a variable in Begin Play)
on Tick > Get World Rotation of this stored camera actor/component > Rinterp the dynamic Actor’s world rotation (zeroing out any irrelevant axes) to the camera’s world rotation)
As I frequently bang on about… Ue4 rotators need careful handling, often it’s unwise to break out one of the float axes perform an operation on it and plug it back into a rotator. Try always to perform operations like math, rinterp and lerp on full rotators. Floats have no understanding of the special wraps needed at 360,180,90 whereas rotators have it built in.
Hey thanks for suggestion. I just tried this and it is giving the same kind of rotation I have before. Pretty sure I have a simple math problem here, I don’t know how to “zero out the axis” at certain points here.