I need help with this movement system

i need help with this type of movement
When you press up, down, left, right, i cant find a way to transport it perfectly to that block
image

Use the position behavior and you can either use the grid movement, or pixel movement. Each grid in the editor is 32 by 32 pixels so if you want to move by pixels, just add 32 or -32 (Depending on direction) into the position behavior’s +X or +Y input to add coordinates onto the players current coordinates.

1 Like

so something like this?

yeah

1 Like

uhh but that will go through walls

1 Like

not if i put a block that kills the user it it gets out lol

Or you could just raycast in the direction the player is trying to move, and simply not move the player if the raycast hits a wall.

1 Like

What .-.
Idk how to use raycast XD

1 Like

A raycast is basically drawing a line in a direction (the angle), and it will output whether it hits something. So in that context, the player would shoot a raycast in the direction where its trying to move (e.x. You press D to move right, and the raycast would shoot at 90°, which is right). So, the raycast would be looking to hit a wall (you can select what the raycast looks for inside the block), and if the raycast hits the wall, it would output from the hit output. So then if the hit output was outputted, it wouldn’t activate the movement code.

1 Like

Thanks for this, it will be helpful

1 Like

Glad I could help! Raycast is useful for lots of other stuff as well.

1 Like

Flowlab Game Creator - Grid Movement Example

Here’s an example by the one and only grazer for a grid-based movement. This might explain a bit better on what you’re trying to achieve. Plus, it has wall collisions.

3 Likes