Moving static speed to outside of inertia resolve function.
This commit is contained in:
parent
3b37b568c5
commit
a0aae4fbcb
|
|
@ -144,19 +144,27 @@ func calculate_velocity(_delta :float,
|
||||||
var foo = 2+2
|
var foo = 2+2
|
||||||
## We are always moving from h_speed.x towards y at a given rate
|
## We are always moving from h_speed.x towards y at a given rate
|
||||||
## if we have a difference of speed and an acceleration
|
## if we have a difference of speed and an acceleration
|
||||||
|
if is_zero_approx(calc_acceleration.x) == false:
|
||||||
calc_inertia.x = resolve_inertia(
|
calc_inertia.x = resolve_inertia(
|
||||||
h_range_placement,
|
h_range_placement,
|
||||||
calc_inertia.x ,
|
calc_inertia.x ,
|
||||||
h_speed,
|
h_speed,
|
||||||
(calc_acceleration.x * _delta)
|
(calc_acceleration.x * _delta)
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
if is_zero_approx(move_direction.x) == false:
|
||||||
|
calc_inertia.x = h_speed.x
|
||||||
|
|
||||||
|
if is_zero_approx(calc_acceleration.y) == false:
|
||||||
calc_inertia.y = resolve_inertia(
|
calc_inertia.y = resolve_inertia(
|
||||||
v_range_placement,
|
v_range_placement,
|
||||||
calc_inertia.y ,
|
calc_inertia.y ,
|
||||||
v_speed,
|
v_speed,
|
||||||
(calc_acceleration.y * _delta)
|
(calc_acceleration.y * _delta)
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
if is_zero_approx(move_direction.y) == false:
|
||||||
|
calc_inertia.y = v_speed.x
|
||||||
|
|
||||||
## Track or last speed for in range impulses
|
## Track or last speed for in range impulses
|
||||||
# _h_impulse_speed_tracking = h_speed
|
# _h_impulse_speed_tracking = h_speed
|
||||||
|
|
@ -291,22 +299,22 @@ func resolve_inertia(range_placement :int,
|
||||||
max(inertia, speed_range.y))
|
max(inertia, speed_range.y))
|
||||||
|
|
||||||
|
|
||||||
elif inertia != 0.0 and is_zero_approx(delta_acceleration) == false: ## We still have inertia but no difference in movement
|
elif is_zero_approx(inertia) == false: ## We still have inertia but no difference in movement
|
||||||
var clamped_speed = speed_range.x
|
var clamped_speed = speed_range.x
|
||||||
if speed_range.x < speed_range.y:
|
if speed_range.x < speed_range.y:
|
||||||
clamped_speed = clamp(speed_range.x,0.0,speed_range.y)
|
clamped_speed = clamp(speed_range.x,0.0,speed_range.y)
|
||||||
|
|
||||||
## Move back towards the base speed
|
## Move back towards the base speed
|
||||||
inertia = move_toward(inertia, clamped_speed, delta_acceleration)
|
inertia = move_toward(inertia, clamped_speed, delta_acceleration)
|
||||||
|
##TODO: This hopefully won't happen (the commented else statement) but I wonder
|
||||||
else:
|
## if I should do anyting here now.
|
||||||
## inertia is just base speed
|
# else:
|
||||||
inertia = speed_range.x
|
# ## inertia is just base speed
|
||||||
if debug and speed_range.x == -90:
|
# inertia = speed_range.x
|
||||||
var foo = 2+2
|
# if debug and speed_range.x == -90:
|
||||||
|
# var foo = 2+2
|
||||||
|
|
||||||
return inertia
|
return inertia
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user