Download

Rotate object by swiping on mobile device

Hello, pretty new to blueprint and am in need of some help, i’ve been trying to create a block that will rotate 90° in the direction you swipe it on a phone and am completely lost, im able to get it to rotate a little but im looking for it to lerp to the new rotation. any help would be appreciated.

cbf9ead7ee52c73cdfbf51e5fd78476b9aa030b6.jpeg

The main problem is that you are only calling the rotation once on a single frame. Basically when touch starts you lerp one step. You want this to continue to be called until it reaches the target rotation.

The easiest way to accomplish this as a beginner, in my opinion, is by using something called a “Timeline.” The introductory blueprint videos on YouTube made by EpicGames use this method to open a sliding door if I recall correctly. Its not too different (though a touch more complicated only because rotators are 3 numbers rather than 1) to get that to work with rotation rather than sliding. You would need to store the starting position so that the lerp is able to interpolate properly.

Sometimes timelines and lerps with floats endup with trash decimals at the end, there’s really no harm in them most of the time but on “Finish” I always force it to the final value, just in case. But that’s entirely optional.

As for setting up the timeline, right click on an empty part of the graph and click “add timeline” and name the resulting node. Then double click on it to go into the timeline editing menu. Click the little “F” to add a float track, whatever you name it appears on the timeline node on the event graph. I set the time to “0.5” Then right click on the big empty area and click “add keyframe” - set its time and value to “0” then add another with its time “0.5” and value “1”

Wow, was not expecting a reply so quickly, ill try it and see how it woulds ill keep you posted, thank you! :smiley:

-----Edit----
Works great thank you for the help. now just got to make it smart to know which way you are swiping on a mobile device