fix: unsuccessful ledge grabs abort properly
This commit is contained in:
parent
6f232373bd
commit
7baa148c53
3 changed files with 15 additions and 13 deletions
BIN
project/assets/character/player/player.blend
(Stored with Git LFS)
BIN
project/assets/character/player/player.blend
(Stored with Git LFS)
Binary file not shown.
Binary file not shown.
|
|
@ -10,6 +10,7 @@ radius = 0.4
|
|||
[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_f46kd"]
|
||||
|
||||
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_ykyjo"]
|
||||
fadeout_time = 0.02
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_vqq2l"]
|
||||
animation = &"hang-clamber"
|
||||
|
|
@ -26,6 +27,8 @@ animation = &"RESET"
|
|||
animation = &"jump"
|
||||
|
||||
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_eqqp1"]
|
||||
fadein_time = 0.05
|
||||
fadeout_time = 0.05
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_42cpl"]
|
||||
animation = &"hang"
|
||||
|
|
@ -79,7 +82,6 @@ animation = &"wallrun_right"
|
|||
[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_eqqp1"]
|
||||
|
||||
[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_uxov2"]
|
||||
graph_offset = Vector2(-710.9436, -530.98883)
|
||||
nodes/output/position = Vector2(1140, 140)
|
||||
nodes/RunStates/node = SubResource("AnimationNodeStateMachine_3nfmf")
|
||||
nodes/RunStates/position = Vector2(-400, -560)
|
||||
|
|
@ -183,8 +185,9 @@ func _physics_process(_delta : float):
|
|||
var direction : Vector3 = -body.velocity
|
||||
if body.is_on_wall():
|
||||
direction = body.get_wall_normal()
|
||||
direction = Vector3(direction.x, 0, direction.z).normalized()
|
||||
if not direction.is_zero_approx():
|
||||
last_direction = Vector3(direction.x, 0, direction.z).normalized()
|
||||
last_direction = direction
|
||||
global_position = body.global_position + Vector3.UP + last_direction * dist_mul
|
||||
"
|
||||
|
||||
|
|
@ -209,20 +212,18 @@ func _enter() -> int:
|
|||
resource_name = "PlayerLedgeHangAction"
|
||||
script/source = "extends PlayerAction
|
||||
|
||||
var wall_normal : Vector3
|
||||
|
||||
func _enter() -> int:
|
||||
blackboard.anim.set(\"parameters/Ledge/request\", AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE)
|
||||
wall_normal = body.get_wall_normal()
|
||||
blackboard.character.look_at(blackboard.character.global_position - Vector3(wall_normal.x, 0, wall_normal.z))
|
||||
return Running
|
||||
|
||||
func _execute() -> int:
|
||||
if not blackboard.hang_ray.is_colliding():
|
||||
return Fail
|
||||
blackboard.anim.set(\"parameters/Ledge/request\", AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE)
|
||||
var diff : Vector3 = blackboard.hang_ray.get_collision_point() - blackboard.hang_ray.global_position
|
||||
var direction : Vector3 = -blackboard.character.global_basis.z
|
||||
if body.is_on_wall():
|
||||
direction = -body.get_wall_normal()
|
||||
blackboard.character.look_at(blackboard.character.global_position + Vector3(direction.x, 0, direction.z))
|
||||
body.velocity = Vector3(body.velocity.x * 0.7, diff.y * 15., body.velocity.z * 0.7)
|
||||
var input_dot_wall : float = body.get_wall_normal().dot(blackboard.get_world_move_input())
|
||||
var input_dot_wall : float = wall_normal.dot(blackboard.get_world_move_input())
|
||||
if diff.length() < 0.05 and input_dot_wall < -0.5:
|
||||
return Success
|
||||
return Running
|
||||
|
|
@ -238,6 +239,7 @@ script/source = "extends PlayerAnimationAction
|
|||
func _exit():
|
||||
blackboard.anim.set(\"parameters/Air/blend_amount\", 0.0)
|
||||
blackboard.anim.set(\"parameters/Wall/blend_amount\", 0.0)
|
||||
blackboard.anim.set(\"parameters/Ledge/request\", AnimationNodeOneShot.ONE_SHOT_REQUEST_ABORT)
|
||||
"
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_nmc1l"]
|
||||
|
|
@ -386,7 +388,7 @@ air_blend_speed = 6.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)
|
||||
top_level = true
|
||||
target_position = Vector3(0, -1.792, 0)
|
||||
target_position = Vector3(0, -1.604, 0)
|
||||
hit_back_faces = false
|
||||
script = SubResource("GDScript_f46kd")
|
||||
dist_mul = -0.508
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue