Compare commits

...

2 Commits

2 changed files with 23 additions and 5 deletions

View File

@ -1135,7 +1135,7 @@ func _on_sprint_state_tick(delta: float) -> void:
soft_force_change_state(&'jump')
elif top_speed_proximity < 0.375:
state = &'run'
elif _get_effective_impetus().dot(linear_velocity) <= -0.75:
elif _get_effective_impetus().dot(linear_velocity) <= -0.96875:
state = &'skid'
func _on_jump_state_start() -> void:

View File

@ -82,10 +82,12 @@ func _respond_to_impetus(delta: float) -> void:
)
look_impetus = Vector3.ZERO
func _try_go(where: Vector3, from: Vector3 = global_position) -> void:
func _find_closest_safe_spot(
where: Vector3, from: Vector3 = global_position
) -> Vector3:
_raycast_object.from = from
_raycast_object.to = where + (
(where - global_position).normalized()*clip_margin
(where - from).normalized()*clip_margin
)
if target:
_raycast_object.exclude = [target]
@ -103,10 +105,26 @@ func _try_go(where: Vector3, from: Vector3 = global_position) -> void:
)
if target && !allow_losing_target:
allow_losing_target = true
_try_go(desired_position, target.global_position)
var posn_a := _find_closest_safe_spot(
desired_position, target.global_position
)
if target is Character && target.is_node_ready():
var posn_b := _find_closest_safe_spot(
desired_position,
target.global_position + target.height*target.global_basis.y
)
if (
(posn_b - desired_position).length() <
(posn_a - desired_position).length()
):
posn_a = posn_b
allow_losing_target = false
return posn_a
else:
global_position = desired_position
return desired_position
func _try_go(where: Vector3) -> void:
global_position = _find_closest_safe_spot(where)
func snap_to_target() -> void:
if !target: return