Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Stop sprites bouncing when using gravity.
- Hotwire
-
100+ posts
Stop sprites bouncing when using gravity.
Something I've never figured out is how to add gravity so that sprites don't fall into blocks but also don't bounce.
http://scratch.mit.edu/projects/14757194/
Here's what I mean.
Currently if it's touching the ground the character will move up, if not the character to will move down.
The y velocity is set to 5 if touching the ground to stop the character falling in.
I can do double layers on the ground and reduce it, but I can't do it with just one layer.
http://scratch.mit.edu/projects/14757194/
Here's what I mean.
Currently if it's touching the ground the character will move up, if not the character to will move down.
The y velocity is set to 5 if touching the ground to stop the character falling in.
I can do double layers on the ground and reduce it, but I can't do it with just one layer.
- lederniersamourai
-
500+ posts
Stop sprites bouncing when using gravity.
You might add acceleration, i.e. “velocity” of velocity.
When touching the ground acceleration makes velocity decrease.
When moving this will make velocity increase.
Note the if your accelration take only v3 values for instance (0, 1, 5 and same negative values), you can encode that in the formulas that change the velocity.
When touching the ground acceleration makes velocity decrease.
When moving this will make velocity increase.
Note the if your accelration take only v3 values for instance (0, 1, 5 and same negative values), you can encode that in the formulas that change the velocity.
- Hotwire
-
100+ posts
Stop sprites bouncing when using gravity.
Did you look at the project I posted? You might add acceleration, i.e. “velocity” of velocity.
When touching the ground acceleration makes velocity decrease.
When moving this will make velocity increase.
Note the if your accelration take only v3 values for instance (0, 1, 5 and same negative values), you can encode that in the formulas that change the velocity.
- Hotwire
-
100+ posts
Stop sprites bouncing when using gravity.
No, that will not allow the sprite to rise when below the background.
If travelling along the line it won't follow it.
- drmcw
-
1000+ posts
Stop sprites bouncing when using gravity.
That's why it's bouncing. Either set it to a small value or change the way you do things and have a repeat until not touching, move -1 function to move out the ground.
- Hotwire
-
100+ posts
Stop sprites bouncing when using gravity.
change the way you do things and have a repeat until not touching, move -1 function to move out the ground.*sigh* thanks for not helping… That's why it's bouncing. Either set it to a small value or
- AonymousGuy
-
1000+ posts
Stop sprites bouncing when using gravity.
I would use a sensor sprite (could even be a clone of the main sprite) which checked to see if it was on the ground.
- Hotwire
-
100+ posts
Stop sprites bouncing when using gravity.
Oh, right… explain more? I would use a sensor sprite (could even be a clone of the main sprite) which checked to see if it was on the ground.
- AonymousGuy
-
1000+ posts
Stop sprites bouncing when using gravity.
Oh, right… explain more? I would use a sensor sprite (could even be a clone of the main sprite) which checked to see if it was on the ground.
I made an example project which shows this method using a sprite which creates a clone of itself. Sorry if the project is hard to understand!
- Hotwire
-
100+ posts
Stop sprites bouncing when using gravity.
Ah, dw I've got something now.
Last edited by Hotwire (Nov. 29, 2013 19:04:02)
- xlk
-
100+ posts
Stop sprites bouncing when using gravity.
put this in a custom block set to run without screen refresh: Ah, dw I've got something now.
repeat until <not<touching BG>>
change y by
- drmcw
-
1000+ posts
Stop sprites bouncing when using gravity.
Going back to the beginning…what's wrong with setting yv to 1 or is that still too bouncy?
- Hotwire
-
100+ posts
Stop sprites bouncing when using gravity.
Yes, it also means that the sprite will fall into the blocks before coming back out to make small bounces on the surface. Going back to the beginning…what's wrong with setting yv to 1 or is that still too bouncy?
- lederniersamourai
-
500+ posts
Stop sprites bouncing when using gravity.
So, what you meant is thant when touching ground, you want to move to the exact (perpendicular) distance between ground and the bottom of your sprite.
You can do that by making a block computing that with a binary search with an auxiliary sprite that is shown but made totally ghost.
This is what drmcw proposed except that had to be done on an auxiliary sprite …
You can do that by making a block computing that with a binary search with an auxiliary sprite that is shown but made totally ghost.
This is what drmcw proposed except that had to be done on an auxiliary sprite …
- Hotwire
-
100+ posts
Stop sprites bouncing when using gravity.
Problem is resolved no worries. So, what you meant is thant when touching ground, you want to move to the exact (perpendicular) distance between ground and the bottom of your sprite.
You can do that by making a block computing that with a binary search with an auxiliary sprite that is shown but made totally ghost.
This is what drmcw proposed except that had to be done on an auxiliary sprite …
- 1timetraveler
-
11 posts
Stop sprites bouncing when using gravity.
i am working on a project (Test) that envolves just this so ill give you the link when its finished or just look on my page
- Discussion Forums
- » Help with Scripts
-
» Stop sprites bouncing when using gravity.