This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-06-05 14:55:45

megnut99
New Scratcher
Registered: 2012-01-28
Posts: 7

Jumping and moving in midair

Hi, I'm trying to make a platformer, but the most I can accomplish for jumping is just up and down. I need to be able to move left and right while in mid-jump, but I can't find anything to help me with that...if anyone can help, that would be great! The script I'm using right now is

when gf clicked
forever
   if <key [up arrow v] pressed?>
   set [gravity v] to [15]
   change y by (10)
      repeat until <touching color [white] ?>
         change [gravity v] by (-1)
         change y by (gravity)
      end
   end
end
it also won't let me fall off platforms, insteadi just walk out onto thin air!
any help is appreciated. thanks!

Offline

 

#2 2012-06-05 15:00:00

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Jumping and moving in midair

Go here to read what the Wiki editors have to say about jumping. The most realistic jumping script is at the bottom.  smile


Why are the secret organizations getting all the attention?  mad

Offline

 

#3 2012-06-05 15:19:13

megnut99
New Scratcher
Registered: 2012-01-28
Posts: 7

Re: Jumping and moving in midair

I also need to be able to jump diagonally, i dont know if you could help me with that,,,

Offline

 

#4 2012-06-05 15:21:10

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Jumping and moving in midair

As long as you can move on the ground left and right, it should still work in the air. Just hold the up and left keys together, or right key and up, it should work.


Why are the secret organizations getting all the attention?  mad

Offline

 

#5 2012-06-10 20:04:35

lalala3
Scratcher
Registered: 2008-10-03
Posts: 100+

Re: Jumping and moving in midair

Don't use a 'repeat until touching ground'. Add a separate 'if' statement for what to do when it's touching the ground (make it set its y velocity to 0 or something), and leave the part where your gravity variable decrements and the part where the object moves outside the 'if' statements. Then add in 'if' statements for movement left and right.


http://img515.imageshack.us/img515/9374/signature2nt.png

Offline

 

Board footer