I don’t know what language that is, but it’s not Javascript.

## 21 Replies - 2696 Views - Last Post: 07 September 2013 - 04:59 PM

### #17

## Re: physics help needed , bouncing ball

Posted 07 September 2013 - 03:37 PM

since that code above what i have done is , everytime if hits floor or reaches its new height(comingup) i reset time and it seems to go i suppose smoother and technically does get faster on them last few bounces before it comes to a stop

here is a link to video of the ball bouncing so you can see what is happening now

http://www.youtube.c...h?v=2CA4ZGNY0G0

here is a link to video of the ball bouncing so you can see what is happening now

http://www.youtube.c...h?v=2CA4ZGNY0G0

### #18

## Re: physics help needed , bouncing ball

Posted 07 September 2013 - 03:47 PM

### #19

## Re: physics help needed , bouncing ball

Posted 07 September 2013 - 04:09 PM

oh sorry ye its unity (javascript)

ok looking at this now ... the ball starts coming up but as it reaches its next height it still have upward velocity hence it looks like its being pushed back down....

so i was saying that when the ball hits the ground or hits its highest point then the time resets to 0 and that error above is happening so when i just say that the time only resets once the ball starts to fall i find that the ball doesnt reach its highest point and only goes up half of what its supposed to using the equation below

velocity -= acceleration * Mathf.Pow(Time.time/60,2);

any ideas where im going wrong?

logic would say..i know the distance it has to travel , i know the starting speed so somehow with them degrade the speed until it becomes 0 as it reaches highest point?

ok looking at this now ... the ball starts coming up but as it reaches its next height it still have upward velocity hence it looks like its being pushed back down....

so i was saying that when the ball hits the ground or hits its highest point then the time resets to 0 and that error above is happening so when i just say that the time only resets once the ball starts to fall i find that the ball doesnt reach its highest point and only goes up half of what its supposed to using the equation below

velocity -= acceleration * Mathf.Pow(Time.time/60,2);

any ideas where im going wrong?

logic would say..i know the distance it has to travel , i know the starting speed so somehow with them degrade the speed until it becomes 0 as it reaches highest point?

This post has been edited by **bboyzeez**: 07 September 2013 - 04:11 PM

### #20

## Re: physics help needed , bouncing ball

Posted 07 September 2013 - 04:45 PM

Quote

here is a link to video of the ball bouncing so you can see what is happening now

yupp, looks like you use wrong functions.

- line #10, v = g·t² ??? (m/s ≠ m/s² · s²)

let’s derive the function h(t):

- in general, a distance is the product of velocity and time: s(t) = v·t (given that v is constant over time)
- we know that’s not the case (v being constant), so we break it up into smaller parts: ds = v(t)·dt
- this is to be integrated, ∫ ds = s(t) - s(0) = ∫ v(t) dt
- at t = 0 let s(0) = 0 and v(0) = starting velocity (√(2·g·h[max]))
- the velocity is changed by (positive or negative) acceleration: dv = a dt (a = const.)
- integration yields: v(t) - v(0) = a·(t - t(0)) = a·t => v(t) = v(0) + a·t (a = –9.81 m/s²)
- putting that into the above integral: s(t) = ∫ v(0) + a·t dt
- reorganisation yields: s(t) = v(0) ∫ dt + a ∫ t dt
- solving (and renaming) that yields: h(t) = v(0)·t - g/2 · t² (g = 9.81 m/s²)
- thus we have derived the height equation for a full bounce

edit: when omitting item 3, the equation becomes somewhat more general: s(t) = s(0) + v(0)·t + (a/2)·t² (a and v(0) are positive if directed the same as s, which is usually upwards). here you can directly see the the equation for and upward-only and downward-only bounce as well as the derivations of distance: ds/dt = v, d²s/dt² = a

tip:

**in equations, always compare the units. if they don’t match up, the equation is wrong.**

This post has been edited by **Dormilich**: 08 September 2013 - 03:36 AM

### #21

## Re: physics help needed , bouncing ball

Posted 07 September 2013 - 04:54 PM

ok thanks its going to take some time to understand what all that means that you wrote (i seriously didnt get to learn gsce physics yet alone anything higher so these symbols i will write and and see what each mean and then work it out and get back to you

### #22

## Re: physics help needed , bouncing ball

Posted 07 September 2013 - 04:59 PM