Pages: 1
Hey all!
So i'm working on a side-scroller beat 'em up and I've added gravity to my game to better enhance the gaming experience! The only problem is whenever my sprite jumps, he falls through the floor! Does anyone know what could possibly be the problem with this? I have a ground sprite that is supposed to prevent the sprite from falling through but he falls through anyway!
Any help would be appreciated! Thanks!
Offline
Do you use velocity?
Offline
The problem might be that he is going so fast down that he completely "misses" the ground and seems to fall right through. I have no idea how to fix this problem though, sorry :\
Offline
If it does use velocity you can limit it. for example, you set it so that if the velocity is faster then x, then the velocity is set to x.
What bob6 said is true
Offline
No, I only use Gravity.
Offline
can you publish your thing? just so that we can take a look and tell you exactly
Offline
So would velocity fix the problem?
Offline
Alright, hold on...
Offline
How do I share my project? I'm using Scratch BYOB
Offline
Well, I couldn't upload it so I took a screenshot instead.
http://imgur.com/DPvBgc8
Offline
I also set Gravity to "-17" when the green flag is clicked. If that helps any.
Offline
I think the falling speed is so high, that the sprite misses, and falls right through.
The way to limit the speed could be to add this script:
when gf clicked forever set [gravity v] to ((gravity) * (0.93))Also, when you fall, using a "repeat until" block stops all of the other blocks in that script until the "repeat until" action is done. Maybe you could replace the section with the "if <key [w v] pressed?>" with
if <key [w v] pressed?> switch to costume [up v] set [gravity v] to (17) change y by (15) end if <touching color [#F0D1B3]?> set [gravity v] to (1) change y by (gravity) switch to costume [stand v] else switch to costume [up v] change [gravity v] by (-1) change y by (gravity) end
Last edited by powerpoint56 (2013-02-19 21:02:02)
Offline
Alright, so I replaced the code with powerpoint56's recommended code but now he doesn't come back down at all!
Offline
I uploaded another screenshot of that as well. The sprite never falls back down, he just stays up.
http://imgur.com/vqlOoUA
Offline
That's strange. I'd suggest maybe in a forever loop putting
when gf clicked set [gravity v] to () //whatever you want the gravity to be at at the beginning forever set [gravity v] to ((gravity)*(0.92)) change y by (gravity)That might help the problem; that way you don't have to put in "change y by (gravity)" every single time he jumps and falls.
Offline
Maybe this project can help you a bit ...
It's a physics-engine with comments for better understanding the script-parts:
http://scratch.mit.edu/projects/Sqervay/3093325
Offline
Wow, that Scratch game is PERFECT! Thanks for the link, Sqervay! And a big thanks to everyone else too for helping me out!
Offline
Pages: 1