Swithing to move_toward based acceleration. All accel would have to be positive.
This commit is contained in:
parent
ad0b1a9595
commit
d4077cff43
|
|
@ -184,10 +184,18 @@ func new_move_actor_as_desired(_delta :float,
|
|||
calc_acceleration.x = resolve_h_acceleration(movement_params, h_speed, move_direction.x)
|
||||
|
||||
## Direction of inertia not equal to move direction
|
||||
## If inertia is applying in a direction
|
||||
if calc_inertial_dir.x:
|
||||
## And it doesn't apply in the same direction as our movement direction
|
||||
if calc_inertial_dir.x != sign(move_direction.x):
|
||||
## flip the direction of acceleration
|
||||
calc_acceleration.x *= -1
|
||||
## flip the direction of acceleration and apply as friction
|
||||
#calc_friction.x = calc_acceleration.x * -1
|
||||
calc_friction.x = calc_acceleration.x
|
||||
calc_acceleration.x = 0.0
|
||||
|
||||
|
||||
|
||||
## We are always moving from h_speed.x towards y at a given rate
|
||||
|
||||
## if we have a difference of speed
|
||||
if h_speed.x != h_speed.y:
|
||||
|
|
@ -195,8 +203,18 @@ func new_move_actor_as_desired(_delta :float,
|
|||
## Clamp inertia to in between speed.
|
||||
# Problem is that we can suddenly gain or lose inertia.
|
||||
##
|
||||
calc_inertia.x = clamp( calc_inertia.x + (calc_acceleration.x * _delta),
|
||||
h_speed.x , h_speed.y)
|
||||
# calc_inertia.x = clamp( calc_inertia.x + (calc_acceleration.x * _delta),
|
||||
# h_speed.x , h_speed.y)
|
||||
## If there is currently no inertia apply the base h_speed
|
||||
if calc_inertia.x == 0.0:
|
||||
calc_inertia.x = h_speed.x
|
||||
## Apply acceleration
|
||||
calc_inertia.x = move_toward(calc_inertia.x, h_speed.y, (calc_acceleration.x * _delta))
|
||||
## Apply friction
|
||||
calc_inertia.x = move_toward(calc_inertia.x, 0, (calc_friction.x * _delta))
|
||||
# calc_inertia.x = clamp( calc_inertia.x + (calc_friction.x * _delta),
|
||||
# 0 , h_speed.y)
|
||||
|
||||
|
||||
## Disable this for now hopefully inertial acceleration flip removes this
|
||||
## Update: it mostly did. Going to keep this here for a while though.
|
||||
|
|
@ -294,13 +312,20 @@ func resolve_h_speed(_params :Dictionary) -> Vector2:
|
|||
if _params["_base_h_move_speed_modifier"] != 0:
|
||||
var speed_differance = base_speed + _params["_base_h_move_speed_modifier"]
|
||||
|
||||
#return(Vector2(base_speed, speed_differance))
|
||||
## We start at a slower base speed and move upward
|
||||
if speed_differance > base_speed:
|
||||
# if sign(_params["_base_h_move_speed_modifier"]) == -1:
|
||||
# return Vector2(speed_differance, base_speed)
|
||||
# else:
|
||||
# return Vector2(base_speed, speed_differance)
|
||||
|
||||
|
||||
return(Vector2(base_speed, speed_differance))
|
||||
else:
|
||||
## We start at a higher speed and move downward to base
|
||||
return(Vector2(speed_differance, base_speed ))
|
||||
## We start at a slower base speed and move upward
|
||||
## Disabled because flipping accel direction may make more sense.
|
||||
# if speed_differance > base_speed:
|
||||
# return(Vector2(base_speed, speed_differance))
|
||||
# else:
|
||||
# ## We start at a higher speed and move downward to base
|
||||
# return(Vector2(speed_differance, base_speed ))
|
||||
# if inertia:
|
||||
# return Vector2(0,inertia)
|
||||
return Vector2(base_speed,base_speed)
|
||||
|
|
@ -318,6 +343,8 @@ func resolve_h_acceleration(_params :Dictionary, _speed :Vector2, _move_directio
|
|||
## Well this didn't work
|
||||
#_acceleration = _params["_base_h_move_acceleration"] + _params["_base_h_move_modifier_move_acceleration"]
|
||||
|
||||
#return _acceleration
|
||||
|
||||
if _speed.x < _speed.y:
|
||||
return _acceleration
|
||||
elif _speed.x > _speed.y:
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ debug_state = false
|
|||
timeout_seconds = 0.0
|
||||
name = "idle"
|
||||
horizontal_speed = 1.36422e-12
|
||||
horizontal_acceleration = 0.0
|
||||
horizontal_acceleration = 2.0
|
||||
horizontal_speed_offset = 0.0
|
||||
horizontal_speed_offset_acceleration = 0.0
|
||||
jerk_factor = 0.0
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ script = ExtResource( 1 )
|
|||
debug_state = false
|
||||
timeout_seconds = 0.0
|
||||
name = "move"
|
||||
horizontal_speed = 90.0
|
||||
horizontal_acceleration = 180.0
|
||||
horizontal_speed_offset = -80.0
|
||||
horizontal_speed = 10.0
|
||||
horizontal_acceleration = 20.0
|
||||
horizontal_speed_offset = 80.0
|
||||
horizontal_speed_offset_acceleration = 0.0
|
||||
jerk_factor = 0.0
|
||||
animation_sequence = [ "run" ]
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ script = ExtResource( 1 )
|
|||
debug_state = false
|
||||
timeout_seconds = 0.0
|
||||
name = "roll"
|
||||
horizontal_speed = 10.0
|
||||
horizontal_speed = 150.0
|
||||
horizontal_acceleration = 1.36422e-12
|
||||
horizontal_speed_offset = 140.0
|
||||
horizontal_speed_offset_acceleration = 150.0
|
||||
horizontal_speed_offset = -140.0
|
||||
horizontal_speed_offset_acceleration = 30.0
|
||||
jerk_factor = 0.0
|
||||
animation_sequence = [ "roll" ]
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user