Rotating an object relative to camera direction
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!
asked Jul 11 '19 at 10:10 PM in Blueprint Scripting
hey Zawa :)
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.
Follow this question
Once you sign in you will be able to subscribe for any updates here