Draggable Object Still Moving Diagonally

I’m creating a puzzle game where all objects can be dragged on touchscreen only in left, right, up, and down directions. When dragging it in one of these directions into another object it matches, it will eliminate both objects. I’m able to get the objects to collide and disappear, but every object can move diagonally even after disabling diagonal movements.

Object Behaviors are set to:
Draggable
StayOnScreen
TopDownMovement (Allow diagonals is unchecked)

Tried adding the below conditions/action:
Condition: NewSprite3 is being dragged
Condition: The cursor/touch is on NewSprite3
Action: Allow diagonal moves for NewSprite3: no

How can I limit the draggable objects to only move left, right, up or down with touch and/or a mouse?

TopDownMovement and Draggable are two separate things that shouldn’t interact. TopDown is for D-Pad style movement. There is no allow diagonals setting for Draggable, that is a TopDown action which prevents you from moving diagonally by pressing two directional buttons at the same time.

You’ll have to think of your own method to limit the object’s movement, which will depend on how your game is set up. I can think of a few different approaches off the top of my head:

  • If the objects can only slide along one axis, then you could brute force the other coordinate. What I mean is, if it slides on X, keep the Y position stored in a variable and then when the object is being dragged, set Y position to the stored value.
  • If there are walls or the objects always have a clear path that is only wide enough for 1 object, then you could use collision with the walls/path to limit the movement
  • On an open grid, you can check the next grid space to see if it is not diagonal (either X or Y should be equal)