| … | … | @@ -21,6 +21,12 @@ export var cameraLerpAmount : float = 40 |
| 21 | 21 | export var currentSpeed : float = 0 |
| 22 | 22 | |
| 23 | 23 | onready var meshNode : Spatial = $Model |
| 24 | onready var meshSkeletonNode : Skeleton = $Model/Armature/Skeleton | |
| 25 | onready var meshSkeletalIKNode : SkeletonIK = $Model/Armature/Skeleton/SkeletonIK | |
| 26 | onready var meshSkeletonHiddenHand : MeshInstance = $Model/Armature/Skeleton/player001 | |
| 27 | onready var meshHandBone : int = meshSkeletonNode.find_bone("DEF-hand.R") | |
| 28 | onready var meshHandBonePos : Transform = meshSkeletonNode.get_bone_pose(meshHandBone) | |
| 29 | ||
| 24 | 30 | onready var clippedCamera : Spatial = $CameraHead/CameraPivot/ClippedCamera |
| 25 | 31 | onready var clippedCameraHead : Spatial = $CameraHead |
| 26 | 32 | onready var clippedCameraPivot : Spatial = $CameraHead/CameraPivot |
| … | … | @@ -38,6 +44,9 @@ onready var grappleLineHelper : Spatial = $Model/GrappleLineHelper |
| 38 | 44 | onready var grappleVisualLine : CSGCylinder = $Model/GrappleLineHelper/GrappleVisualLine_1 |
| 39 | 45 | # onready var grappleVisualLine : = $Model/GrappleLineHelper/GrappleVisualLine_2 |
| 40 | 46 | |
| 47 | onready var grappleIKTarget : Position3D = $GrapplingHook/IKTarget | |
| 48 | onready var grapplingHandOriginalScale : Vector3 = Vector3.ZERO | |
| 49 | ||
| 41 | 50 | var grapplingHook_GrapplePosition : Vector3 = Vector3.ZERO |
| 42 | 51 | var grapplingHook_IsHooked : bool = false |
| 43 | 52 | var playerWantsToShootGrapplingHook : bool = false |
| … | … | @@ -101,14 +110,6 @@ func getSpawnLocation() -> Vector3: |
| 101 | 110 | func _process(_delta): |
| 102 | 111 | if(currentDirection != Vector3.ZERO): |
| 103 | 112 | meshNode.rotation.y = lerp_angle(meshNode.rotation.y, atan2(-currentDirection.x, -currentDirection.z), turn_velocity * _delta) |
| 104 | return | |
| 105 | var meshSkel : Skeleton | |
| 106 | meshSkel = meshNode.find_node("Skeleton", true) | |
| 107 | var bone = meshSkel.find_bone("DEF-hand.R") | |
| 108 | var bonePos = meshSkel.get_bone_pose(bone) | |
| 109 | bonePos = bonePos.scaled( Vector3(0, 0, 0) ) | |
| 110 | meshSkel.set_bone_pose(bone, bonePos) | |
| 111 | #meshSkel.add_child(boneAttachment) | |
| 112 | 113 | |
| 113 | 114 | func grapplingHook_Process(): |
| 114 | 115 | grapplingHook_CheckActivation() |
| … | … | @@ -127,12 +128,17 @@ func grapplingHook_CheckActivation(): |
| 127 | 128 | # grapplingHook_GrapplePosition = grappleHookCast.get_collision_point() |
| 128 | 129 | grappleVisualLine.show() |
| 129 | 130 | $Model/Sound_Shoot_GrapplingHook_2.play() |
| 131 | grappleIKTarget.translation = grapplingHook_GrapplePosition | |
| 132 | grapplingHook_DisappearHand() | |
| 133 | ||
| 130 | 134 | elif(playerWantsToReleaseGrapplingHook): |
| 131 | 135 | # Stop grappling |
| 132 | grapplingHook_IsHooked = false | |
| 133 | playerWantsToReleaseGrapplingHook = false | |
| 134 | grappleVisualLine.hide() | |
| 135 | $Model/Sound_Release_GrapplingHook.play() | |
| 136 | if(grapplingHook_IsHooked): | |
| 137 | grapplingHook_IsHooked = false | |
| 138 | playerWantsToReleaseGrapplingHook = false | |
| 139 | grappleVisualLine.hide() | |
| 140 | $Model/Sound_Release_GrapplingHook.play() | |
| 141 | grapplingHook_ReappearHand() | |
| 136 | 142 | |
| 137 | 143 | func grapplingHook_UpdateVisualPoint(): |
| 138 | 144 | if grappleHookCast.is_colliding(): |
| … | … | @@ -173,6 +179,20 @@ func grapplingHook_UpdatePlayerVelocityAndReturnHookLength() -> float: |
| 173 | 179 | kinematicVelocity += player2hook.normalized() * force |
| 174 | 180 | |
| 175 | 181 | return length |
| 182 | ||
| 183 | func grapplingHook_DisappearHand(): | |
| 184 | meshSkeletonHiddenHand.visible = false | |
| 185 | #var bone = meshSkeletonNode.find_bone("DEF-hand.R") | |
| 186 | #var bonePos = meshSkeletonNode.get_bone_pose(bone) | |
| 187 | #bonePos = bonePos.scaled( Vector3(0.1, 0.1, 0.1) ) | |
| 188 | #meshSkeletonNode.set_bone_custom_pose(bone, bonePos) | |
| 189 | ||
| 190 | func grapplingHook_ReappearHand(): | |
| 191 | meshSkeletonHiddenHand.visible = true | |
| 192 | #var bone = meshSkeletonNode.find_bone("DEF-hand.R") | |
| 193 | #var bonePos = meshSkeletonNode.get_bone_pose(bone) | |
| 194 | #bonePos = bonePos.( Vector3(1, 1, 1) ) | |
| 195 | #meshSkeletonNode.set_bone_custom_pose(bone, bonePos) | |
| 176 | 196 | |
| 177 | 197 | var jumpingUp : bool |
| 178 | 198 | func _physics_process(_delta): |
| … | … | @@ -225,6 +245,12 @@ func _physics_process(_delta): |
| 225 | 245 | |
| 226 | 246 | # Update Grappling Hook |
| 227 | 247 | grapplingHook_Process() |
| 248 | ||
| 249 | # Check for Hand IK from Grappling Hook | |
| 250 | if(grapplingHook_IsHooked): | |
| 251 | meshSkeletalIKNode.start() | |
| 252 | else: | |
| 253 | meshSkeletalIKNode.stop() | |
| 228 | 254 | |
| 229 | 255 | |
| 230 | 256 | # self.linear_velocity.y += jumpHeight |
| … | … | @@ -85,7 +85,7 @@ attenuation_filter_cutoff_hz = 20500.0 |
| 85 | 85 | transform = Transform( 1.53846, 0, 0, 0, 1.53846, 0, 0, 0, 1.53846, 0, 0.753, 0 ) |
| 86 | 86 | |
| 87 | 87 | [node name="GrappleVisualLine_1" parent="Model/GrappleLineHelper" instance=ExtResource( 34 )] |
| 88 | transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0.753, 0 ) | |
| 88 | transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0.753, -0.121675 ) | |
| 89 | 89 | visible = false |
| 90 | 90 | |
| 91 | 91 | [node name="AnimationPlayer" type="AnimationPlayer" parent="."] |
| … | … | @@ -10,7 +10,7 @@ |
| 10 | 10 | [node name="PlayerCoreLocal" instance=ExtResource( 1 )] |
| 11 | 11 | |
| 12 | 12 | [node name="SkeletonIK" parent="Model/Armature/Skeleton" index="2"] |
| 13 | target_node = NodePath("../../../../CameraHead/CameraPivot/Position3D") | |
| 13 | target_node = NodePath("../../../../GrapplingHook/IKTarget") | |
| 14 | 14 | |
| 15 | 15 | [node name="Sound_Jump" parent="Model" index="2"] |
| 16 | 16 | transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ) |
| … | … | @@ -40,18 +40,18 @@ enabled = true |
| 40 | 40 | cast_to = Vector3( 0, 0, -400 ) |
| 41 | 41 | collision_mask = 2 |
| 42 | 42 | debug_shape_custom_color = Color( 1, 0, 0, 1 ) |
| 43 | debug_shape_thickness = 5.0 | |
| 43 | debug_shape_thickness = 5 | |
| 44 | 44 | |
| 45 | 45 | [node name="ClippedCamera" type="ClippedCamera" parent="CameraHead/CameraPivot" index="1"] |
| 46 | 46 | transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 2.5 ) |
| 47 | 47 | fov = 90.0 |
| 48 | 48 | |
| 49 | [node name="Position3D" type="Position3D" parent="CameraHead/CameraPivot" index="2"] | |
| 50 | transform = Transform( -0.454202, 0.376862, -0.807264, 0.862653, -0.0403142, -0.504187, -0.222553, -0.925392, -0.30679, -0.5, -0.53716, -1.2328 ) | |
| 51 | ||
| 52 | 49 | [node name="PlayerDebugUI" parent="." index="7" instance=ExtResource( 5 )] |
| 53 | 50 | |
| 54 | [node name="GrappleVisualPoint_1" parent="GrapplingHook" index="0" instance=ExtResource( 4 )] | |
| 51 | [node name="IKTarget" type="Position3D" parent="GrapplingHook" index="0"] | |
| 52 | transform = Transform( -0.454202, 0.376862, -0.807264, 0.862653, -0.0403142, -0.504187, -0.222553, -0.925392, -0.30679, 0, 0.96284, -1.2328 ) | |
| 53 | ||
| 54 | [node name="GrappleVisualPoint_1" parent="GrapplingHook" index="1" instance=ExtResource( 4 )] | |
| 55 | 55 | |
| 56 | 56 | [connection signal="player_jump" from="Input" to="." method="_on_Input_player_jump"] |
| 57 | 57 | [connection signal="player_mousemotion_event" from="Input" to="." method="_on_Input_player_mousemotion_event"] |
| … | … | @@ -17,6 +17,11 @@ func _input(_event): |
| 17 | 17 | Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) |
| 18 | 18 | else: |
| 19 | 19 | Input.set_mouse_mode(mouseModeBackup) |
| 20 | if Input.is_action_just_pressed("toggle_slowmo"): | |
| 21 | if Engine.get_time_scale() < 1.0: | |
| 22 | Engine.set_time_scale(1.0) | |
| 23 | else: | |
| 24 | Engine.set_time_scale(0.1) | |
| 20 | 25 | |
| 21 | 26 | func _process(_delta): |
| 22 | 27 | pass |
| … | … | @@ -187,4 +187,4 @@ nodes/walk_scale/node = SubResource( 23 ) |
| 187 | 187 | nodes/walk_scale/position = Vector2( -640, 360 ) |
| 188 | 188 | nodes/wall_run/node = SubResource( 50 ) |
| 189 | 189 | nodes/wall_run/position = Vector2( 720, -60 ) |
| 190 | node_connections = [ "output", 0, "wall_run", "Blend2", 0, "Animation 8", "Blend2", 1, "Animation 9", "Blend2 2", 0, "Animation 11", "Blend2 2", 1, "Animation 10", "TimeScale 3", 0, "strafe", "aim_transition", 0, "TimeScale 3", "aim_transition", 1, "iwr_blend", "air_blend", 0, "jump_scale", "air_blend", 1, "falling_scale", "air_blend", 2, "landing_scale", "air_transition", 0, "air_blend", "air_transition", 1, "aim_transition", "falling_scale", 0, "Animation 6", "iwr_blend", 0, "Animation 2", "iwr_blend", 1, "walk_scale", "iwr_blend", 2, "run_scale", "jump_scale", 0, "jump", "landing_scale", 0, "Animation 7", "roll", 0, "air_transition", "roll", 1, "roll_scale", "roll_scale", 0, "Animation", "run_scale", 0, "Animation 4", "walk_scale", 0, "Animation 3", "wall_run", 0, "Blend2", "wall_run", 1, "Blend2 2", "wall_run", 2, "roll" ] | |
| 190 | node_connections = [ "output", 0, "wall_run", "roll", 0, "air_transition", "roll", 1, "roll_scale", "TimeScale 3", 0, "strafe", "jump_scale", 0, "jump", "Blend2 2", 0, "Animation 11", "Blend2 2", 1, "Animation 10", "run_scale", 0, "Animation 4", "landing_scale", 0, "Animation 7", "walk_scale", 0, "Animation 3", "air_transition", 0, "air_blend", "air_transition", 1, "aim_transition", "wall_run", 0, "Blend2", "wall_run", 1, "Blend2 2", "wall_run", 2, "roll", "aim_transition", 0, "TimeScale 3", "aim_transition", 1, "iwr_blend", "Blend2", 0, "Animation 8", "Blend2", 1, "Animation 9", "iwr_blend", 0, "Animation 2", "iwr_blend", 1, "walk_scale", "iwr_blend", 2, "run_scale", "falling_scale", 0, "Animation 6", "roll_scale", 0, "Animation", "air_blend", 0, "jump_scale", "air_blend", 1, "falling_scale", "air_blend", 2, "landing_scale" ] |
| … | … | @@ -159,6 +159,11 @@ shoot_grapplinghook={ |
| 159 | 159 | "events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null) |
| 160 | 160 | ] |
| 161 | 161 | } |
| 162 | toggle_slowmo={ | |
| 163 | "deadzone": 0.5, | |
| 164 | "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":90,"physical_scancode":0,"unicode":0,"echo":false,"script":null) | |
| 165 | ] | |
| 166 | } | |
| 162 | 167 | |
| 163 | 168 | [physics] |
| 164 | 169 |