# How do I simulate 'bouncing' higher the farther you fall

Just started using Construct 2? Post your questions here

### » Thu Nov 20, 2014 12:08 am

Greetings,

I have a sprite that is not solid and if the Platform collides with it a 'Jump' function is simulated. I have attached an image of my current setup.

A problem I have encountered with this is holding the 'Jump' key while colliding with the sprite that makes you jump stops you from jumping and nothing happens. I'm also trying to make it so the farther you fall onto the sprite that makes you jump, the higher you jump (to a point).

I've been trying to solve this for a while. Thank you for your help.
You do not have the required permissions to view the files attached to this post.
B
10
S
2
G
2
Posts: 87
Reputation: 1,274

### » Thu Nov 20, 2014 9:20 am

Hi varr. Can you grab the ypos at the top of the fall and compare it with the ypos at the bottom of the fall then use the distance in some kind of "power" formula?
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

### » Thu Nov 20, 2014 11:30 am

Instead of changing jump strength and jumping you could just set the Yvelocity directly.
So to replicate the bounce you have you could do something like
Set Yvelocity to -500

Or since you want it to bounce based on height you can just invert the Yvelocity to do a bounce.
Set Yvelocity to -abs(Yvelocity)
B
95
S
34
G
128
Posts: 5,495
Reputation: 81,678

### » Fri Nov 21, 2014 6:05 am

Thanks for the replies! I'll play around with both. -abs stands for absolute? That would make the 'bounce' based on the highest value for Yvelocity at the time it's set? I am a very huge newbie when it comes to coding.
B
10
S
2
G
2
Posts: 87
Reputation: 1,274

### » Sat Feb 27, 2016 10:35 am

Message: bloodshot can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
@R0J0hound I found your ball_bounce.capx over at how-do-i-simulate-a-bouncing-ball-w-o-physics-or-bullet_t121046

Forgive me for being such a blockhead, but how do you decrease the bouncing momentum overtime? (So it won't bounce forever) Many thanks!
B
15
S
7
G
34
Posts: 55
Reputation: 18,478

### » Sat Feb 27, 2016 11:50 pm

@bloodshot
Just multiply the speed by an value between 0 and 1 when it bounces
Set Yvelocity to -0.5*abs(Yvelocity)
B
95
S
34
G
128
Posts: 5,495
Reputation: 81,678