How to smooth move actor on discrete space – solution for beginners.

Hello,

This is not a question but a solution of a problem I troubled with for a week because I can’t google it. Maybe I just ask wrong question (it’s quite possible since my English skill is rather poor). Anyway I will leave it here. Maybe this will be helpful for beginners like me or maybe someone more experienced than me will show us better ( == more elegant) solution.

I was having problems with discrete player movement. Imagine a pawn that can move for 100 units up,down, left, right (like figure on the chessboard – player can stand only in specific locations). If you wish just “teleport” actor it’s not a problem. You need blueprint like this:

Same for Up and Down of course. And everything work as expected. You press left: pawn teleport left for 100 units. Great. Now let’s say you wish to make move like this but not teleport player – you need smooth move. At first I make something like this:

Same for other 3 events. And now problem hit. When you timeline need let’s say 1 sec (like in my case) to execute and you hit: left, left, right keyboard keys (in that order) really fast you will notice weird pawn behavior. It’s start move smooth but then jump in a bit chaotic way. My first approach to fix this was to add variable “can_move” (bool). So after input action, first we check this variable – if it say “true” we set it to “false” and continue execute. After finishing execute we set it to “true”. This is like semaphore – we solve the problem right? NOPE. And here it came hard part for beginner. I was not aware that “timeline” is something like spawning thread in C++ - it execute in non blocking way to rest of the blueprint! So idea with putting semaphore is basically good – you just need to set “can_move” to true again using “Finished” pin from Timeline (for me it’s like thread.join() in C++) and NOT from update pin of curse!

Good lord – it was so easy (and logical….) all the time :slight_smile: Maye this post will save some beginner some time.

Best regards,

Yansen.