In this video
you will make the hero look like it's walking
only while it's actually moving forward.
You probably noticed your hero
currently looks like it never stops walking.
The looks loop doesn't know whether or not
the hero is moving forward.
This video will fix that.
Make a variable.
Your first variable should have been called up down speed,
or something like that.
This variable will keep track of the same thing,
but in a left right direction.
Call it left right speed,
or X speed,
or whatever makes sense to you.
Click okay.
In the looks loop
make it animate only if the X speed is not zero.
Snap an if block around everything in the loop.
To make the condition
left right speed does not equal zero,
use two operator blocks.
First put a knot then inside place an equal.
Type zero into one side of the equals block.
Then snap the new variable into the other side.
Look at the motion loop
and find something that will communicate
to the looks loop that the hero is moving.
Use the broadcasted message forward
to communicate whether the hero
should do it's walking animation.
From events grab another when I receive block
and choose forward from the drop down.
Under your new event block
set the variable to one to indicate that it's moving.
It's a little tricky
because there's no message to say stop moving forward.
But you do know that the forward message keeps getting sent
as long as the hero is moving.
So, just wait.
If the message doesn't get sent again,
the hero has stopped moving.
Below the set variable block snap a weight block.
Then another set variable block,
where you will set the left right speed back to zero.
Tinker with the value in the weight block test.
A small value is probably best.
This example we used zero point one.
Great, the hero looks like its walking
only while it's actually moving forward.
The project page gives you a space
to explain your project to others in Scratch.
Write some instructions for how to use your project.
Be specific.
Tell them which keys to push and how to make it work.
Now it's your turn.
Add a new variable left right speed.
Make the conditional if left right speed is not zero,
then snap all the looks loop blocks inside.
When the hero receives forward
have it set the left right speed to one,
wait for a short time,
then set the left right speed back to zero.