hello
i am making a halo game and i really need help with grav.
when i jump ON TO a box its fine but after that when i walk off the side of the box i just float at the same hight as the b0x.
if some1 could give me a script for gravity that would let me fall to my original height when i fall off the box i would be so grateful!
ty
Last edited by doctorgoo (2009-02-11 15:20:54)
Offline
Essentially, you want to have a script that is constantly making the sprite fall (changing its y by a negative amount), except at the times when it's touching something solid. Simple example:
forever if (not <touching [ground]>) {
change y by (-1)
}
Last edited by mrweston (2009-02-11 15:22:09)
Offline
How so? Might need to use a variable or two to get it to only activate the gravity when not doing those things:
When Space key pressed {
set $jumping to (1)
broadcast Jump and wait
set $jumping to (0)
}
forever if (not <touching [ground]>) AND ($jumping = 0) {
change y by (-1)
}
Or something like that.
Last edited by mrweston (2009-02-11 15:30:08)
Offline
hmm ill explain my whole game to you just to make shure
you start off just standing there and there are lots of black items you can drag and drop to make your own level
i have sorted out making them solid but i need to fall off them when i walk off them
(if you play halo 3 you wil know what forge is, well this is a scratch version of it)
Offline
are they all the same colour? if so, simply have something looking like this
forever{
if (touching colour (select colour)){
grav = 0
} else {
change grav by -1
}
if(Key up Arrow is pressed){
if(grav = 0){
grav = 5
}
}
change y by grav
}
Offline
Here, download this http://scratch.mit.edu/projects/shadowwarrior77/417818 and take a look at its scripting, then just use it...its pretty simple and its great!
Also, you can change how high and how fast he falls by changing the Yvelocity
It should work, just make sure to put a black outline on everything you want the sprite to walk on or land on
Enjoy,
-Shadow
Offline
For super simple gravity & movement look here
http://scratch.mit.edu/projects/archmage/72848
Offline
you need to have a sprite, a color, or maybe a function that can be sensed so that you can sense whether or not you are touching a "floor". If what you really want is true GRAVITY you need some advanced physics, which would mean you need velocity. you can have a yvel variable and change y by yvel. I'm not sure how you are sensing whether you are touching a box... I wouldn't know the best way to do t so that it worked with your current scripts. I would need an example of it.
Offline