Input retained top down behaviour

Hi, I’m trying to build a game of battle between ships. Those ships should be allowed to move only along an axis. During a non-combat period the player can move in 8 directions. When an enemy ship enters the screen both the ships go their axes (which is decided based on their position; e.g. the “higher” one will go the “higher” axis) and the battle starts. During combat the player can move only along the axis.

For the combat setup I’ve used lerp, so that looks smooth but I encountered a problem. When the lerp instruction is read if I have a key pressed (specifically “w” or “s” since the lerp is vertical) there’s conflict and the event is not executed correctly (e.g. the ship stops not on the axis).

So I tried to disable the behaviour for a little time after the setup begins. It solved the problem partially: the ship would get on the axis but, as soon as the behaviour is activated once again, the input I was giving moves the ship, like a little jump. I presume this happens because the input, or the speed, is kinda retained. I’ve tried to stop the player, deactivate, wait and then reactivate, but it does nothing.

Any help for this? I think deleting the inputs would help but I don’t know how to do it.

Before you turn the behaviour back on, set the X and Y speeds to 0 :

image

1 Like

What a lad. Works just as intended, thank you!