Help writing function to instantly rotate third person character to face thumbstick direction

Good day,

I would like some help with a blueprint function whose aim is to instantly rotate the third person character to face whatever direction is currently on the left thumbstick. (typically the input axes) The direction the character is currently facing in game should have no effect on the desired rotation, which should come from the thumbstick relative to the camera.

This image should give a clear idea of what I’m trying to do.

I’ve tried quite a few ways of doing this and kinda got it to work if the camera is at a specific location, though if the camera moves then it breaks. Failed experiments look something like:

For testing this function I’ve disabled input after calling it, so that thumbstick movement after the function is called won’t interfere with the testing. Jerky animation is fine, don’t care about smoothing the rotation.
Thanks in advance for any assistance.

Your [Get Control Rotation] seems a bit different from the one I see. I assume it’s a custom function?

By looking at your references to both an actor and a pawn, can I assume that your “camera character” is simply following the pawn but not attached via an arm? It also seems that you’re using the pawn’s rotation to make an offset. I’m not 100% sure what your preference is on how the character should move in relation to your view, but I am pretty sure your functions are based on the rotation for the actor/pawn/character and not the actual world location and rotation of the camera view itself. In any case, one of these methods may work for you:

When I’m in the blueprint editor, the [Get Control Rotation] node I see that references the pawn has an output pin of a rotation rather than the rotation break there. The one I see has a description of “Get the rotation of the controller, often the ‘view’ rotation of this pawn.” Either way, it wouldn’t be any different; using the pawn’s rotation (presumably, the one holding the camera view you are using) to get the offset would be futile since it does not actually return the rotation for the actual camera, rather the way the pawn’s root, or “eyes”, would be facing.

The [Get Base Aim Rotation] node is probably the actual function you were thinking the aforementioned node would be.

Other options would be: [Get View Rotation] (if you used a {Viewport} reference); [Camera Component} (reference)->[Get Camera View]->[Break MinimalViewInfo]->(Rotation) pin; [Delta (Rotator)]

So, first of all, your game controller’s input:

[Get Input Analog Input State]->[Make Rot from YX] or [Make Rot from XY]

You can even use [Hypotenuse], [Absolute (float)] and delta seconds with [Normalize to Range] to calculate the intensity. Find out what its max length is and you can use [Normalize to Range] again to determine how much of 100% of the intensity to use, if that makes sense. Add a [Curve] object and you can change its exponential intensity.

Use [Nearly Equal (float)] to see if the [Hypotenuse] is close to 0 in order to avoid oversensitive jerking.

Now that you have an angle from the analog stick, use one of the aforementioned methods above to get the camera’s actual rotation. Then, use [Delta (Rotator)] to account for the offset your camera is currently facing. From there, [Set Actor Rotation] should be applied to the actor you are rotating. Notice that this didn’t have to take into account its current rotation.

I hope this helps; let me know if this works out to your satisfaction.

Thanks for the info Zakku. I’ll try some more today.

This is pretty much the standard third person blueprint setup, camera on a springarm, no custom functions, so anyone can attempt it.

Your [Get Control Rotation] seems a bit different from the one I see. I assume it’s a custom function?
It’s the standard one, just click on the output value of the node and click on Split Struct Pin to be able to separate the output like that.

It also seems that you’re using the pawn’s rotation to make an offset.
Was just experimenting as some functions which take a vector input really just want 3 numbers as input and use ‘vector’ as a quick way of saying give me 3 numbers.

I’m not 100% sure what your preference is on how the character should move in relation to your view
No lateral movement, just a simple instant rotation in place to face the direction currently on the thumbstick, relative to the view.
For eg. if character is facing North, camera is behind the character also facing North, then user presses thumbstick South-East and calls this function, the character will instantly rotate 135 degrees right (ie “South East”), the camera does not move.

In that case, the node I mentioned would be the one to use. You can easily get the direction you want to face by normalizing the analog’s “up” position to the actual camera’s rotation.

I’ve never seen any guides or tutorials on normalizing an input based on the rotation of an actor. Any link or blueprint screenshot would be insanely helpful. Thanks again, you’ve given me some ideas to work with on this.

I generally answer questions while en route to someplace so I just describe what needs to be done in order to get the wheels turning, hence the lack of a screenshot.

Normalization is a common practice with software engineering and data structures. It basically orientates the data to each other so that they are on the same page. In this instance, you’re aligning the analog stick to the camera’s world rotation so that they’re on the same page. Literally a rotation subtracted by a rotation-- exactly what you were doing in the blueprint.

No prob, thanks for the help, I’ll update this post when I figure it out.

After a lot of fiddling around I’ve come up with a function that seems to work.

After a lot of experimenting I’ve come up with a function that seems to work fine so far, posted above. Thanks again.