chore: adjusted skidding and running
This commit is contained in:
parent
4690eeb99a
commit
dba2c4fc30
1 changed files with 36 additions and 21 deletions
|
|
@ -135,7 +135,8 @@ script/source = "extends AnimationTree
|
|||
|
||||
@export var full_speed : float
|
||||
@export var min_skid_speed : float
|
||||
@export var skid_blend_speed : float
|
||||
@export var skid_blend_speed_in : float
|
||||
@export var skid_blend_speed_out : float
|
||||
@export var jump_to_fall_speed : float
|
||||
@export var air_blend_speed : float
|
||||
|
||||
|
|
@ -153,12 +154,18 @@ func property_move_toward(property : String, target, speed) -> float:
|
|||
else:
|
||||
set(property, new_value)
|
||||
return new_value
|
||||
|
||||
|
||||
func process_skid_blend(delta : float, speed : float):
|
||||
var current_deceleration_blend = get(\"parameters/Decelerating/blend_amount\")
|
||||
var deceleration_distance : float = 0.0 if behaviour_tree.get_world_move_input().dot(body.velocity) > 0.5 else clamp(speed / min_skid_speed, 0.0, 1.0)
|
||||
var skid_blend_speed : float = skid_blend_speed_in if deceleration_distance >= current_deceleration_blend else skid_blend_speed_out
|
||||
property_move_toward(\"parameters/Decelerating/blend_amount\", deceleration_distance, delta * skid_blend_speed)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
var speed : float = Vector2(body.velocity.x, body.velocity.z).length()
|
||||
set(\"parameters/Speed/scale\", clamp(speed / full_speed, 0.0, 1.0))
|
||||
var deceleration_distance : float = 0.0 if behaviour_tree.get_world_move_input().dot(body.velocity) > 0.0 else clamp(speed / min_skid_speed, 0.0, 1.0)
|
||||
property_move_toward(\"parameters/Decelerating/blend_amount\", deceleration_distance, delta * min_skid_speed)
|
||||
set(\"parameters/Speed/scale\", clamp(speed / full_speed, 0.0, 2.0))
|
||||
process_skid_blend(delta, speed)
|
||||
property_move_toward(\"parameters/Moving/blend_amount\", 1.0 if speed > 0.05 else 0.0, delta * default_blend_time)
|
||||
var in_air : bool = 1.0 == property_move_toward(\"parameters/Air/blend_amount\", 0.0 if body.is_on_floor() else 1.0, delta * air_blend_speed)
|
||||
if in_air:
|
||||
|
|
@ -179,6 +186,9 @@ var last_direction : Vector3 = Vector3.BACK
|
|||
func _ready() -> void:
|
||||
add_exception(body)
|
||||
|
||||
func _process(_delta : float):
|
||||
_physics_process(_delta)
|
||||
|
||||
func _physics_process(_delta : float):
|
||||
if Engine.is_editor_hint() and body:
|
||||
global_position = body.global_position + Vector3.UP * height + Vector3.BACK * dist_mul
|
||||
|
|
@ -196,6 +206,9 @@ func _physics_process(_delta : float):
|
|||
resource_name = "PlayerHighWallRay"
|
||||
script/source = "extends RayCast3D
|
||||
|
||||
func _physics_process(_delta : float):
|
||||
_process(_delta)
|
||||
|
||||
func _process(_delta : float):
|
||||
target_position = $\"../HangRay\".global_position - global_position
|
||||
global_rotation = Vector3.ZERO
|
||||
|
|
@ -213,9 +226,9 @@ func _ready():
|
|||
|
||||
func _enter() -> int:
|
||||
blackboard.hang_ray.force_raycast_update()
|
||||
blackboard.ground_ray.force_raycast_update()
|
||||
blackboard.high_wall_ray.force_raycast_update()
|
||||
if not timeout and not body.is_on_floor() and blackboard.hang_ray.is_colliding() and not blackboard.high_wall_ray.is_colliding():
|
||||
blackboard.ground_ray.force_raycast_update()
|
||||
var wall_normal_y : float = blackboard.hang_ray.get_collision_normal().y
|
||||
var edge_distance : float = blackboard.hang_ray.get_collision_point().distance_to(blackboard.hang_ray.global_position)
|
||||
if wall_normal_y > 0.9 and body.is_on_wall() and blackboard.get_ground_distance() > edge_distance:
|
||||
|
|
@ -357,18 +370,18 @@ func _enter() -> int:
|
|||
resource_name = "FallingAction"
|
||||
script/source = "extends PlayerAction
|
||||
|
||||
@export var drag : float = 0.001
|
||||
@export_range(0.0, 1.0, 0.001) var drag : float = 0.001
|
||||
|
||||
func _enter() -> int:
|
||||
if not body.is_on_floor() or blackboard.get_ground_distance() > 1.0:
|
||||
func _execute() -> int:
|
||||
if not body.is_on_floor():
|
||||
body.velocity *= 1.0 - drag
|
||||
body.velocity += body.get_gravity() * get_process_delta_time()
|
||||
var look_direction := Vector3(blackboard.character.global_basis.z.x, 0, blackboard.character.global_basis.z.z)
|
||||
blackboard.character.look_at(blackboard.character.global_position - look_direction)
|
||||
blackboard.anim.property_move_toward(\"parameters/Wall/blend_amount\", 0.0, get_process_delta_time() * 15)
|
||||
return Success
|
||||
else:
|
||||
return Fail
|
||||
if not body.is_on_wall():
|
||||
return Running
|
||||
return Fail
|
||||
"
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_eqqp1"]
|
||||
|
|
@ -396,14 +409,13 @@ func _enter() -> int:
|
|||
"
|
||||
|
||||
[node name="Player" type="PlayerBody" unique_id=591139793]
|
||||
floor_snap_length = 0.46
|
||||
floor_max_angle = 0.87266463
|
||||
floor_snap_length = 0.2
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=1143027860]
|
||||
shape = SubResource("CapsuleShape3D_bxedw")
|
||||
|
||||
[node name="GroundRay" type="RayCast3D" parent="." unique_id=1763928231]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.96605223, 0)
|
||||
enabled = false
|
||||
target_position = Vector3(0, -500, 0)
|
||||
hit_back_faces = false
|
||||
|
||||
|
|
@ -430,22 +442,25 @@ parameters/ClimbUp/internal_active = false
|
|||
parameters/ClimbUp/request = 0
|
||||
script = SubResource("GDScript_i825w")
|
||||
default_blend_time = 30.0
|
||||
full_speed = 7.0
|
||||
min_skid_speed = 5.0
|
||||
skid_blend_speed = 5.0
|
||||
full_speed = 10.0
|
||||
min_skid_speed = 8.0
|
||||
skid_blend_speed_in = 6.0
|
||||
skid_blend_speed_out = 3.0
|
||||
jump_to_fall_speed = 2.0
|
||||
air_blend_speed = 50.0
|
||||
|
||||
[node name="HangRay" type="RayCast3D" parent="PlayerModel" unique_id=183285060]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -0.508)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -0.624)
|
||||
top_level = true
|
||||
enabled = false
|
||||
target_position = Vector3(0, -2, 0)
|
||||
hit_back_faces = false
|
||||
script = SubResource("GDScript_f46kd")
|
||||
dist_mul = -0.508
|
||||
dist_mul = -0.624
|
||||
|
||||
[node name="HighWallRay" type="RayCast3D" parent="PlayerModel" unique_id=2283840]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0)
|
||||
enabled = false
|
||||
target_position = Vector3(0, 0, -0.5)
|
||||
script = SubResource("GDScript_4vq5b")
|
||||
|
||||
|
|
@ -511,6 +526,6 @@ vertical_jump_velocity = 5.0
|
|||
|
||||
[node name="Run" type="PlayerMovementAction" parent="PlayerBehaviourTree/BehaviourRepeater/ActionSelector" unique_id=2080183164]
|
||||
target_speed = 10.0
|
||||
acceleration = 25.0
|
||||
deceleration = 30.0
|
||||
acceleration = 20.0
|
||||
deceleration = 25.0
|
||||
script = SubResource("GDScript_bxedw")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue