@Maybeking wrote:
Hello, me again
!
I'm building my own tiny physic engin for my 2D game engin and I want to implement acceleration and friction on my entities wich have velocity. I find a good equation here : https://stackoverflow.com/questions/667034/simple-physics-based-movementFor people who dont want to click, there is the equation :
velocity += acceleration - friction*velocity
But there is a problem :
Let's say I want to calculate the gravity on my entity (Acceleration = 9.83), so i calculate the velocity Y with the equation, and lets say i have 0.5f of friction. So each game step, the following code is applied to my entity:
velocityY += 9.83f - 0.5f * velocityY
So we have this table of velocity for each step :
Step n : velocityY
1 : 9.83
2 : 14.745
3 : 17.2025
4 : 18.43125
5 : 19.045625
6 : 19.3528
7 : 19.5064
And now, as you can see, at the step 4 we have our velocity which increase very slowly and never pass 20.
I know why it do that, its because :
when the half of the velocity reach near of the half of the gravity (9.83), thefriction*velocity
is almost as much as the gravity.So I need help maybe to change the equation or improve it !
Thanks you !
Posts: 3
Participants: 2