reintroduce calc_velocity variable, allow override for testing.
This commit is contained in:
parent
a9afabf0a1
commit
dff822c6f4
|
|
@ -158,17 +158,21 @@ func new_move_actor_as_desired(_delta :float,
|
||||||
"_gravity" : _state.gravity
|
"_gravity" : _state.gravity
|
||||||
}
|
}
|
||||||
var calc_velocity = Vector2.ZERO
|
var calc_velocity = Vector2.ZERO
|
||||||
|
if _velocity_override.x != 0.0:
|
||||||
|
calc_velocity.x = _velocity_override.x
|
||||||
|
else:
|
||||||
|
calc_velocity.x = velocity.x
|
||||||
|
if _velocity_override.y != 0.0:
|
||||||
|
calc_velocity.y = _velocity_override.y
|
||||||
|
else:
|
||||||
|
calc_velocity.y = velocity.y
|
||||||
|
|
||||||
var calc_acceleration = Vector2.ZERO
|
var calc_acceleration = Vector2.ZERO
|
||||||
var calc_inertia :Vector2
|
var calc_inertia :Vector2
|
||||||
##TODO: make sure velocity variable exists since we rely on it
|
calc_inertia.x = abs(calc_velocity.x)
|
||||||
## Calc from the _velocity_override instead of current object velocity
|
calc_inertia.y = calc_velocity.y
|
||||||
if _velocity_override.x != 0.0:
|
|
||||||
calc_inertia.x = abs(_velocity_override.x)
|
var calc_inertial_dir = Vector2(sign(calc_velocity.x),sign(calc_velocity.y))
|
||||||
else:
|
|
||||||
calc_inertia.x = abs(velocity.x)
|
|
||||||
##TODO: Only implemented horizontal so far.
|
|
||||||
calc_inertia.y = velocity.y
|
|
||||||
var calc_inertial_dir = Vector2(sign(velocity.x),sign(velocity.y))
|
|
||||||
var calc_friction :Vector2 = Vector2.ZERO
|
var calc_friction :Vector2 = Vector2.ZERO
|
||||||
|
|
||||||
## Inertia only applies if there is a difference between the
|
## Inertia only applies if there is a difference between the
|
||||||
|
|
@ -188,7 +192,7 @@ func new_move_actor_as_desired(_delta :float,
|
||||||
move_direction = resolve_move_direction(calc_inertial_dir, desired_movement_vector)
|
move_direction = resolve_move_direction(calc_inertial_dir, desired_movement_vector)
|
||||||
|
|
||||||
## Which direction will acceleration be applied.
|
## Which direction will acceleration be applied.
|
||||||
calc_acceleration.x = resolve_h_acceleration(movement_params, velocity, move_direction.x)
|
calc_acceleration.x = resolve_h_acceleration(movement_params, calc_velocity, move_direction.x)
|
||||||
|
|
||||||
## Direction of inertia not equal to move direction
|
## Direction of inertia not equal to move direction
|
||||||
## If inertia is applying in a direction
|
## If inertia is applying in a direction
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user