Making a sprite move left and right based on the cursor

I am making a top down space game but I'm having trouble with the movement. I want the Sprite which is a space ship to look at the cursor to help aim, however, I also want to sprite to move based on where the cursor is. I would like it when you click A or D to move left or right based on where the cursor is.

Welcome to Snap! Forums!

You might want to try this script:

This one is to move left.

This one is to move right.

The warp blocks prevent players from seeing the movements step-by-step, and just so what they see is the sprite moving left or right.

There's no need to warp, as snap is already fast enough to do that without any visual glitches.

You can just use
untitled script pic

That doesn't turn with the user.

That is different from what @mobility212's script. Their script moves around the mouse, whereas your script only moves left and right on the x-axis. Both yield different results.

Was thinking about my own project, my mistake. But the warp blocks aren’t needed unless it’s ridiculously slow

Here are two movement scripts that both point in the direction of the mouse.

This first one moves the sprite around the direction you go, e.g. a = left, d = right, etc.

This second script moves around the direction the sprite is facing. If you press w, it moves forward, if you press s, you move back. If you press a, it moves left relative to the current direction it's facing, same with d, but moving right.

I have a feeling the second script is what @keenendirk is looking for.

Yes this is exactly what I was looking for. Thank you very much!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.