Pages: 1
Topic closed
I have a script for this, but it makes it shake very obviously, AND I can't make the sprite jump off of it without screwing up the script and making the sprite eventually fall. Just so you know, I'm using the "y velocity" variable for jumping. So here's the script I used:
<when green flag clicked>
<forever>
<if><< <touching[ Platform 3 <and> <( <{ y velocity }> <<> -1 )> >>
<set{ y velocity }to( 0
<if><key[ up arrow ]pressed?>
<set{ y velocity }to( 15
<end>
<forever if><< <touching[ Platform 3 <and> <( <{ y velocity }> <<> -1 )> >>
<set y to( (( y position of Platform 3 <+> 35 ))
<end>
So it's supposed to make the sprite jump, but that doesn't work because of the last command which is to set the sprites y position to that of Platform 3. So what else should I use instead of that? And how can I stop it from shaking the sprite?
Last edited by WhiteStone (2010-06-06 05:15:54)
Offline
When Green Flag Clicked
Forever
If Touching Sprite1
Set Y to Y position
Set X to X position
If you don't add "Forever" in there, it will only work for the first millisecond of the game.
Offline
@My Last Post
Oh, I'm sorry. I read it wrong. I might be able to help you later.
Offline
Forever if <touching [moving platform]>
Set [X velocity/momentum] to (Platform Momentum)
Set [Y momentum] to 0
Change y by 1
And on the moving platform
Forever
Set [Platform momentum] to 5
Repeat 10
Move 5 steps
Set [Platform momentum] to -5
Repeat 10
Move -5 steps
Offline
Yeah, that doesn't really work since I have the gravity going forever... I'm sure there's a way to work around that, but I'd like help in figuring that out.
Offline
Hi, I made this for you ;D
It doesn't work online but It does offline.
Check it out: http://scratch.mit.edu/projects/JSO/1105685
Offline
Awesome! Thanks a bunch!
But the problem is now that the jumping works strangely, and your script causes the y velocity to go to 0 as soon as it touches the platform. I guess that's easy to fix though, I could make it so that the sprite can only stop moving if its y velocity is less than 0.
The other problem is that I want to keep the sprite on top of the platform. Since y velocity continually decreases by 1, the y position of the sprite decreases by 1, 2, 3, 4, 5, 6, 7.... and so on. So that causes the sprite to not stop directly on top of the platform. This is easy to solve for stationary platforms such as the ground, but I'm not sure how to do that for moving ones.
Actually, I think I'll post my project to show you how it works. There are some useless scripts that I was playing around with to try and get some things to work... but they didn't. So I hope you could look over those and see what's wrong with them as well as finding a way to solve this problem...
Anyways, your contribution was extremely helpful! Thanks again!
Offline
Just uploaded it. Please check it out and help, that would be awesome!
Offline
I don't really have time right now to help you,
but i suggest you have a look at one of the greatest velocity scripts, Chop Shop.
If that still doesn't help enough, reply to me and i'll provide you with a special project for you.
Hope it helps!
Offline
Topic closed
Pages: 1