Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » need help with gravity
- ShinyCharizardPro
-
Scratcher
1 post
need help with gravity
I'm trying to make a scratch project that makes a clone fall down. the clone should bounce back up on the edge tho
Last edited by ShinyCharizardPro (March 15, 2024 14:04:25)
- BigNate469
-
Scratcher
1000+ posts
need help with gravity
Gravity is a force that pulls everything with mass towards everything else with mass. You are currently being pulled on by atoms hundreds of light-years away, but their force is negligible at this distance.
Simply set the clones to be going down until they hit the edge- if you only need them to bounce and don't care about it looking too realistic, just use scratch's built-in
Otherwise, you have to program in some resistance to going up… and that gets complicated quickly.
Simply set the clones to be going down until they hit the edge- if you only need them to bounce and don't care about it looking too realistic, just use scratch's built-in
if on edge, bounceblock.
Otherwise, you have to program in some resistance to going up… and that gets complicated quickly.
- SpyCoderX
-
Scratcher
1000+ posts
need help with gravity
Gravity is a force that pulls everything with mass towards everything else with mass. You are currently being pulled on by atoms hundreds of light-years away, but their force is negligible at this distance.Scratch's built-in “if on edge, bounce” just handles rotation. It's only useful for a pong game.
Simply set the clones to be going down until they hit the edge- if you only need them to bounce and don't care about it looking too realistic, just use scratch's built-inif on edge, bounceblock.
Otherwise, you have to program in some resistance to going up… and that gets complicated quickly.
For what the OP (original poster) is trying to do, you need to calculate velocity, acceleration, and the correct angle to bounce off of objects.
griffpatch has a tutorial specifically for that: Physics Tutorial
- MKYCATS2
-
Scratcher
100+ posts
need help with gravity
I have an idea for this.
use the gravity script that I like to use:
use the gravity script that I like to use:
when green flag clickedor for the last one
forever
if <<not <(jump) = [0]>> or <not <(jump) < (0)>>> then
change [jump v] by (-1)
set [jump_check v] to (0)
else
if <(jump_check) = [0]> then
set [jump v] to (0)
set [jump_check v] to (1)
end
end
end
when green flag clicked
forever
change y by (jump)
end
when [your key or whatever you want to happen v] key pressed
if <(jump_check) = [1]> then
change [jump v] by (how high you want it to go)
end
when green flag clicked
forever
if <touching [edge v]> then
change [jump v] by (whatever)
end
end
- Create-Scratch101
-
Scratcher
500+ posts
need help with gravity
I have an idea for this.
use the gravity script that I like to use:when green flag clickedor for the last one
forever
if <<not <(jump) = [0]>> or <not <(jump) < (0)>>> then
change [jump v] by (-1)
set [jump_check v] to (0)
else
if <(jump_check) = [0]> then
set [jump v] to (0)
set [jump_check v] to (1)
end
end
end
when green flag clicked
forever
change y by (jump)
end
when [your key or whatever you want to happen v] key pressed
if <(jump_check) = [1]> then
change [jump v] by (how high you want it to go)
endwhen green flag clicked
forever
if <touching [edge v]> then
change [jump v] by (whatever)
end
end
That should work.
- Coding3dnow
-
Scratcher
21 posts
need help with gravity
the equation for gravity is (-16timer^2) that is the gravity to set gravity back to zero set the timer to zero
- Discussion Forums
- » Help with Scripts
-
» need help with gravity