Try this:
create variable gravity, global (for all sprites)
set it to some NEGATIVE number
Then, in each sprite where you want to have gravity, put this script (variable fallv should be local, that is 'for this sprite only'):
<when green flag clicked>
<set{ fallv }to( 0
<forever>
<change{ fallv }by( gravity
<change y by( fallv
<if><( <y position> <<> -179 )>
(now, the sprite has fallen on the ground)
(if you want penalize the sprite for the impact, the energy of the impact is roughly (( <{ fallv }> <*> <{ fallv }> ))
You can do what you want, for example hide the sprite, or if you want to let the sprite stay on the ground, these two lines will help:
<set y to( -179
<set{ fallv }to( 0
<end>
<end>
After you have it for 1 sprite, simply drag it to other sprites, the variable fallv gets crated automatically.
This is only basic thing, of course you will probably customize it for your purpose.
Last edited by deerel (2008-08-26 19:07:39)
Offline
keroro645 wrote:
nevermind do you know how to do like a damage type thing?The more damage you have the farther you go when hit.
You know how you set gravity to a certain number when you jump? Well, make a damage variable and change it by the damage/10 or something
Offline
Bluestribute wrote:
keroro645 wrote:
nevermind do you know how to do like a damage type thing?The more damage you have the farther you go when hit.
You know how you set gravity to a certain number when you jump? Well, make a damage variable and change it by the damage/10 or something
I'm sorry, I don't get it. Neither keroro neither Bluestribute :-) Could you explain slower, maybe I understand and answer... :-|
Offline
Gravity is sort of like velocity then. Except some scripts are a little different. But sorta the same .
Last edited by Juzzy (2008-08-26 18:40:38)
Offline
For gravity try checking out the code in this project.
http://scratch.mit.edu/projects/archmage/58354
Offline
This Is My Way Of Gravity
<when green flag clicked><forever if><< <not> >><touching[Ground Color]<move(Any)steps><point towards(Down]
Offline
ssbbmakering wrote:
This Is My Way Of Gravity
<when green flag clicked><forever if><< <not> >><touching[Ground Color]<move(Any)steps><point towards(Down]
That's not realistic. It just makes things go down if not touching the ground, there's no gradual velocity changes.
Offline