It depends a lot on what you're trying to do. The most basic one is this:
when gf clicked set [y vel v] to (0) forever change [y vel v] by (-1) change y by (yvel)
Offline
Offline
oshe10 wrote:
bob6 wrote:
Are you sure it doesn't work? it works pretty well to me. What do you mean by "it doesn't work" ? Can you explain please?
It makes my sprite go negative
if you mean upside down click the button <-> next to the sprite image at the part where you can change the name of it
Offline
Then you need to create a script that will only let the gravity script work if your sprite is in the air/not on solid ground.
Offline
Here follow two scrips that really work.
The first one use the physics concept of aceleration:
when gf clicked reset timer forever change y by <[-10] * (timer)>or ...
when gf clicked forever change (speed) by [-5] change y by (speed)
Offline
If you want collision too, you should mention that, it helps us know exactly what kind of script you want. I usually use something like this:
when gf clicked set [yvel v] to (0) forever change [yvel v] by (-0.2) change y by (yvel) if<touching [wall/ground v]?> set [yvel v] to ((-0.5)*(yvel)) change y by (yvel) if<touching [wall/ground v]?> change y by (yvel) end if<<key [up arrow v] pressed?> and <(yvel) > (0)>> // for jumping set [yvel v] to (5) end end
Offline