Immediate stop when no accelleration seems to work.
This commit is contained in:
parent
7d210d7900
commit
00de0d6450
|
|
@ -158,8 +158,10 @@ func new_move_actor_as_desired(_delta :float,
|
||||||
}
|
}
|
||||||
var calc_velocity = Vector2.ZERO
|
var calc_velocity = Vector2.ZERO
|
||||||
var calc_acceleration = Vector2.ZERO
|
var calc_acceleration = Vector2.ZERO
|
||||||
#var calc_inertia = Vector2.ZERO
|
var calc_inertia :Vector2
|
||||||
var calc_inertia = velocity.abs()
|
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_inertial_dir = Vector2(sign(velocity.x),sign(velocity.y))
|
||||||
var calc_friction :Vector2 = Vector2.ZERO
|
var calc_friction :Vector2 = Vector2.ZERO
|
||||||
|
|
||||||
|
|
@ -247,7 +249,6 @@ func new_move_actor_as_desired(_delta :float,
|
||||||
## For now, y component of velocity is just gravity
|
## For now, y component of velocity is just gravity
|
||||||
#calc_velocity.y = movement_params["_gravity"] * Vector2.DOWN.y
|
#calc_velocity.y = movement_params["_gravity"] * Vector2.DOWN.y
|
||||||
|
|
||||||
calc_inertia.y = velocity.y
|
|
||||||
calc_inertia.y += movement_params["_gravity"] * _delta
|
calc_inertia.y += movement_params["_gravity"] * _delta
|
||||||
calc_velocity.y = calc_inertia.y
|
calc_velocity.y = calc_inertia.y
|
||||||
|
|
||||||
|
|
@ -255,6 +256,7 @@ func new_move_actor_as_desired(_delta :float,
|
||||||
## Can't do it this way when we have initia
|
## Can't do it this way when we have initia
|
||||||
#calc_velocity.x = calc_inertia.x * move_direction.x
|
#calc_velocity.x = calc_inertia.x * move_direction.x
|
||||||
|
|
||||||
|
## Control, direction can only be controlled when overcome inertia direction.
|
||||||
if calc_inertial_dir.x != 0:
|
if calc_inertial_dir.x != 0:
|
||||||
calc_velocity.x = calc_inertia.x * calc_inertial_dir.x
|
calc_velocity.x = calc_inertia.x * calc_inertial_dir.x
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -319,9 +319,14 @@ func _state_process_physics_move():
|
||||||
if !parent.is_on_floor():
|
if !parent.is_on_floor():
|
||||||
request_state_change.call_func('fall')
|
request_state_change.call_func('fall')
|
||||||
|
|
||||||
|
## First version
|
||||||
#move_actor_as_desired()
|
#move_actor_as_desired()
|
||||||
var _v :Vector2 = new_move_actor_as_desired( physics_delta , current_state )
|
|
||||||
apply_movement_to_parent(_v)
|
## Second One
|
||||||
|
#var _v :Vector2 = new_move_actor_as_desired( physics_delta , current_state )
|
||||||
|
#apply_movement_to_parent(_v)
|
||||||
|
|
||||||
|
apply_movement_to_parent(new_move_actor_as_desired( physics_delta , current_state ))
|
||||||
|
|
||||||
func get_climb_shape_location() -> Vector2:
|
func get_climb_shape_location() -> Vector2:
|
||||||
if $"%LadderDetector".is_colliding():
|
if $"%LadderDetector".is_colliding():
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ debug_state = false
|
||||||
timeout_seconds = 0.0
|
timeout_seconds = 0.0
|
||||||
name = "idle"
|
name = "idle"
|
||||||
horizontal_speed = 1.36422e-12
|
horizontal_speed = 1.36422e-12
|
||||||
horizontal_acceleration = 2.0
|
horizontal_acceleration = 0.0
|
||||||
horizontal_speed_offset = 0.0
|
horizontal_speed_offset = 0.0
|
||||||
horizontal_speed_offset_acceleration = 0.0
|
horizontal_speed_offset_acceleration = 0.0
|
||||||
jerk_factor = 0.0
|
jerk_factor = 0.0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user