How do i detect if a sprite is moving left or right?

I am currently making a game and i need to detect if the sprite is moving left or right.

get the previous and current position and subtract them

script variables ((prev)) @>
forever{
say ((x position)-(prev))
set [prev V] to (x position)

Depending on your movement script, you may be able to use the direction reporter to find out which way the sprite is facing.

I cant drag that in…

here

It doesn’t work for me or Maybe it is just me or i dont know how it works… Ill give a project link! Cube jumper by kingnico1133 | Snap! Build Your Own Blocks
Reminder it isn’t done yet!

try using a wait block or you can just use what the movement code is using

I literally made a block for a problem JUST like this. Although it measures its speed in steps and can’t detect if it’s moving a certain direction. Would you like to use the block anyway?

I could use it can i see it?

Sure, let me inport the link to the block

Here you go! It’s pretty awesome

The second sprite is moving but isn’t in the screen.

Thank you!

The only problem is it can’t detect x movement. It just detects total movement, also it becomes inaccurate when bouncing on walls because it goes off of position and time

It works but for some reason now my code glitches out and for some reason when i try to move forward it moves up instead…

The block is for calculating if a certain object is moving. Not for moving objects

As you said in your first post

I know i set it to to detect if sprite is moving.

Then what’s your issue with your script? I didn’t really understand what you meant here:

I highly recommend setting the block inside a (greater than “2”) because sometimes it bugs and says it’s moving 1 step. While it’s not moving at all

If you move in the game then jump then try to move again it goes up and down instead of left and right

Your script or my block?