Character Rotation on RMB pressed

Hi, i want to implement rotation of the character when i press and hold RMB, so otherwise he will face to where he walking to (like in Signalis, if you are familiar)


The trouble is - i am skill issue, i am able to do it in C++, but since i got from unity to unreal - i wan’t to learn the blueprint as it seems to be way more interesting

This is my current BP and making connection from Right Mouse Button “Pressed exec” to set actor rotation isn’t working, so i’m here.

Thank you in advance

Presumably this is in your character?

( If so, you don’t need an interface call ).

Is it even getting called? Have you tried putting a print string in here?

Not familiar with the game you mentioned, but it looks like it has the character look at the mouse location when aiming, but runs towards directional presses otherwise. Is that about right?

If so, you’ll probably want the character to have UseController’sDesiredDirection and OrientRotationToMovement set to true in the movement component. Then in the player controller class, have the “triggered” pin of an enhanced input action for right mouse call a function to set the controller’s rotation as in your screenshot. With character set to use controller’s rotation, it should rotate smoothly. May need to tweak the character’s rotation rate though.

The started pin there should set the aforementioned OrientRotationToMovement option to false since that overrides control rotation.

Then to get the char walking in the direction of movement keys again, from the “completed” and “cancelled” pins of that input action set OrientRotationToMovement back to true in the character’s movement component.

I did so, and as it seems - there is something with rotation triggering itself, that i don’t understand, because if i remove connection from “every tick” in either controller or character blueprint - it won’t react on any control input.
I had thoughts that it works on constantly rotating every tick and input triggers it only once, enough to be unnoticed by eye, so i tried to find some logic gates like AND, but couldn’t find none

yeah, this is first thing i tried to do and printing a test string to log worked perfectly fine

Yes, it needs to be called every tick.

so is there a way to make ticks pass through RMB to trigger?

On tick, you would need to check if the right mouse button is held.

I don’t know which input system you’re using.

Yea. If you’re using the enhanced input system, the Triggered pin on the input action should fire basically on tick. Well, technically, I guess the frequency is determined by the hardware polling rate, but should be fast enough. This is how they have the clicky movement setup in the topdown project template.

If using raw mouse events or the deprecated action bindings, on mouse clicked/pressed/released, you could simply set a bool which you check with a branch in the tick event.

i’ve had to redo the whole looking & movement system from scratch (which broken whole thing couple times) but yeah, the key was to make IA for mouse with designated RMB, which by itself on Triggered pin will tick as Event Tick

As shown here

1 Like

image

1 Like

(the thing with only one media for new users is frustrating…)

1 Like

It for sure needs couple tweaks, but works completely fine
Also for rotation to movement to work - this
image
needs to be cheked out.

Anyway, thanks a lot you two, i hope someone will find this post useful!

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.