How can I rotate an object over time when pressing a key?

Hey!

I want to rotate an object over time when a player presses a key.

I attached the blueprint i have at this moment and think i’m almost there, i only need some help on the “RInterp To” i think. Thanks for your answers!

Set Actor Rotation will rotate object momentarily on trigger (in this case key press only once per pressed). You need to use Tick so it will trigger node on every frame and move object towards the target,also apply delta time so it it will sync with time. You need to keep target rotation in variable and set on key press and replace current key press with tick also you can block tick when rotation reach the target.

Thanks for your suggestion ****

Although your suggestion was a bit cryptic i managed to find out a way to get it working! For everyone else i added my working solution, and maybe can help other people out looking for a similar solution.

Hi, thanks a lot for your explanations.
I used your graph as I needed this kind of effect on my player, all is working pretty well except that each time I run this script, the character is having the rotation I want +1 or 2 extra degrees, and I can’t figure out how to erase those extra degrees. So after a while running the function, the character’s rotation is completely messed up.

Any idea how to fix it ?
thanks a lot

Use Max/Min function so calculations won’t cross the target rotation

Hey! Since this was something which was annoying me as well and i needed some accuracy as well i redid some work on the script and it looks entirely different now. Here’s the new working solution, also with added functionality that the player cannot keep on pressing the key while the object is still rotating and it stays nicely in sync with an absolute number of degrees.

Again: Here’s the blueprint!

Hey, can you explain custom tick 3, My version of this stops there but when i replace it with event ticks it works. i’d be curious how to setup multiple tick calls.

Why complicate it? Define your key as an axis input and use it with an Add COntroller Yaw Input node. That is what it’s designed for.

Hi TheBat, it’s a great blueprint! I’m trying to apply it to my project but can’t find “SET / the current yaw” node, can you please advise where can I find it?