friction
I''m making a mini golf game. I can make the ball bounce, and move by how much time has gone by.
What is the best way to cause friction? Should I just have a certain amount to slow down, and do the same thing I do with my speed and time since last update, or is there some formula I should be using? Because I don''t think it''s linear.
following is my intuitive guess regarding friction (that seems to work fine):
v''=v * pow(1-fc,elapsed); where elapsed is elapsed time since last frame, v is previous velocity and v'' is current velocity, and fc is friction constant (0<=fc<=1). hope it helps.
v''=v * pow(1-fc,elapsed); where elapsed is elapsed time since last frame, v is previous velocity and v'' is current velocity, and fc is friction constant (0<=fc<=1). hope it helps.
Friction by air can be calculated with this formula:
F = c * rho * A * v^2
Whit lower speeds it looks more like v (not squared) though...
rho = air density
A = area of object in m^2
v = speed in m/s
c = air resistance constant, about 0.4 for spheres, a little less for golf balls.
To use this force to change the speed of the ball, each frame:
a = F/m
v = v + a*dt
s = s + v*dt
where:
m = mass of object
v = velocity (=speed)
s = location of object
dt = amount of passed time (in seconds)
As far as I know friction on the ground is constant, something like:
F = C*g*m
where
m=mass
g=gravitational constant (9.8)
C=some constant you have to fiddle with until it looks right
For friction always use a= -F/m, since you want the ball to slow down
If you want to optimize it a little:
a = c1 * v_old * v_old
if_ball_on_the_ground a = a + c2
v -= a * dt
for some constants c1 and c2.
F = c * rho * A * v^2
Whit lower speeds it looks more like v (not squared) though...
rho = air density
A = area of object in m^2
v = speed in m/s
c = air resistance constant, about 0.4 for spheres, a little less for golf balls.
To use this force to change the speed of the ball, each frame:
a = F/m
v = v + a*dt
s = s + v*dt
where:
m = mass of object
v = velocity (=speed)
s = location of object
dt = amount of passed time (in seconds)
As far as I know friction on the ground is constant, something like:
F = C*g*m
where
m=mass
g=gravitational constant (9.8)
C=some constant you have to fiddle with until it looks right
For friction always use a= -F/m, since you want the ball to slow down

If you want to optimize it a little:
a = c1 * v_old * v_old
if_ball_on_the_ground a = a + c2
v -= a * dt
for some constants c1 and c2.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement