Discuss Scratch

Meme_Master234
Scratcher
58 posts

How to make A character move with WASD?

If anyone can help me code simple movement by pressing
WASD that would be great. If anyone can like copy the code and post it
in the comments that would be great!
when I receive [One comment]

change Mood to [Happy]

Stop[Depression]
kiwilover2736
Scratcher
1000+ posts

How to make A character move with WASD?

Hello!

Here's some code for WASD movement that is smooth. If you don't want velocity you can tell me
Note: You can change the numbers that have a black outline around them to whatever you like!

when green flag clicked
forever
if <key [D] pressed?> then
change [X Velocity] by ((2))
end
if <key [A] pressed?> then
change [X Velocity] by ((-2))
end
if <key [W] pressed?> then
change [Y Velocity] by ((2))
end
if <key [S] pressed?> then
change [Y Velocity] by ((2))
end
change [X Velocity] by ((-1) * ((X Velocity) / ((10))))
change [Y Velocity] by ((-1) * ((Y Velocity) / ((10))))
change x by (X Velocity)
change y by (Y Velocity)
end
Meme_Master234
Scratcher
58 posts

How to make A character move with WASD?

Thanks So much for this!
Now I know what to make next for a project.
when I receive [Help from kiwilover}
say [Thanks so much!]
BigLegoFan
Scratcher
12 posts

How to make A character move with WASD?

move (5) steps
THEIMPORTANT
Scratcher
100+ posts

How to make A character move with WASD?

Smoother

when green flag clicked
forever
change [xvelocity v] by ((<key [right arrow v] pressed?> - <key [left arrow v] pressed?>) * (5))
change [yvelocity v] by ((<key [up arrow v] pressed?> - <key [down arrow v] pressed?>) * (5))
set [xvelocity v] to ((yvelocity) * (0.8))
set [yvelocity v] to ((xvelocity) * (0.8))
change x by (X Velocity)
change y by (Y Velocity)
end

Last edited by THEIMPORTANT (Nov. 19, 2024 07:45:00)

ametrine_
Scratcher
1000+ posts

How to make A character move with WASD?

BigLegoFan wrote:

move (5) steps
please don't blockspam

Powered by DjangoBB