Initial commit.
This commit is contained in:
@@ -0,0 +1,287 @@
|
||||
[gd_scene format=3 uid="uid://0lx4ngfees3q"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cb4kbixfs5g4w" path="res://Assets/Mixamo.gltf" id="1_2ddk3"]
|
||||
[ext_resource type="Script" uid="uid://couw105c3bde4" path="res://addons/godot_state_charts/state_chart.gd" id="1_wb1c3"]
|
||||
[ext_resource type="InputResource" uid="uid://dji2q0ekqofcx" path="res://Input/camera_movement.tres" id="2_vtyg2"]
|
||||
[ext_resource type="Script" uid="uid://jk2jm1g6q853" path="res://addons/godot_state_charts/compound_state.gd" id="3_2ddk3"]
|
||||
[ext_resource type="Script" uid="uid://cytafq8i1y8qm" path="res://addons/godot_state_charts/atomic_state.gd" id="4_baibx"]
|
||||
[ext_resource type="Script" uid="uid://cf1nsco3w0mf6" path="res://addons/godot_state_charts/transition.gd" id="6_j3mgm"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_g15lx"]
|
||||
script/source = "extends CharacterBody3D
|
||||
|
||||
@export var _mesh : Node3D
|
||||
@export var _animation_tree : AnimationTree
|
||||
"
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_2ddk3"]
|
||||
animation = &"JogForward"
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_baibx"]
|
||||
animation = &"RunForward"
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_j3mgm"]
|
||||
animation = &"Walk"
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_tx82o"]
|
||||
animation = &"StandIdle"
|
||||
|
||||
[sub_resource type="AnimationNodeBlendSpace1D" id="AnimationNodeBlendSpace1D_enbxg"]
|
||||
min_space = 0.0
|
||||
sync_mode = 2
|
||||
blend_point_0/node = SubResource("AnimationNodeAnimation_2ddk3")
|
||||
blend_point_0/pos = 0.6
|
||||
blend_point_0/name = &"JogForward"
|
||||
blend_point_1/node = SubResource("AnimationNodeAnimation_baibx")
|
||||
blend_point_1/pos = 1.0
|
||||
blend_point_1/name = &"RunForward"
|
||||
blend_point_2/node = SubResource("AnimationNodeAnimation_j3mgm")
|
||||
blend_point_2/pos = 0.3
|
||||
blend_point_2/name = &"Walk"
|
||||
blend_point_3/node = SubResource("AnimationNodeAnimation_tx82o")
|
||||
blend_point_3/pos = 0.13
|
||||
blend_point_3/name = &"StandIdle"
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_vtyg2"]
|
||||
advance_mode = 2
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_fj36c"]
|
||||
states/walk/node = SubResource("AnimationNodeBlendSpace1D_enbxg")
|
||||
states/walk/position = Vector2(582, 120.329216)
|
||||
transitions = ["Start", "walk", SubResource("AnimationNodeStateMachineTransition_vtyg2")]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_vtyg2"]
|
||||
script/source = "extends Node3D
|
||||
|
||||
@export var camera_input_resource : InputResource
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
InputHandler.add_input_resource(self, camera_input_resource)
|
||||
"
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_6ql8e"]
|
||||
radius = 0.2783203
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_6ql8e"]
|
||||
script/source = "extends Node
|
||||
|
||||
@export_category(\"Nodes\")
|
||||
@export var _controlled_body : CharacterBody3D
|
||||
@export var _camera_rotator_y : Node3D
|
||||
@export var _state_chart : StateChart
|
||||
@export var _animation_tree : AnimationTree
|
||||
|
||||
@export_category(\"Input Settings\")
|
||||
@export var _walk_reaction_speed : float = 1.0
|
||||
|
||||
@export_category(\"Input Resources\")
|
||||
@export var _player_movement : InputResource
|
||||
|
||||
var _target_movement_speed : float = 0.0
|
||||
var _current_movement_speed : float = 0.0
|
||||
var _root_motion_accumulator : Vector3 = Vector3.ZERO
|
||||
|
||||
signal state_changed(StringName)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
InputHandler.add_input_resource(self, _player_movement)
|
||||
|
||||
|
||||
func _process(_delta:float) -> void:
|
||||
_current_movement_speed = lerpf(_current_movement_speed, _target_movement_speed, _delta * _walk_reaction_speed)
|
||||
_animation_tree[\"parameters/walk/blend_position\"] = _current_movement_speed
|
||||
|
||||
_root_motion_accumulator += _animation_tree.get_root_motion_position()
|
||||
|
||||
func _physics_process(_delta:float) -> void:
|
||||
_controlled_body.set_velocity(_root_motion_accumulator / _delta)
|
||||
_controlled_body.move_and_slide()
|
||||
_root_motion_accumulator = Vector3.ZERO
|
||||
|
||||
|
||||
func _on_movement_2d(_delta:float, _vector:Vector2):
|
||||
_target_movement_speed = _vector.length_squared()
|
||||
|
||||
|
||||
func _on_walking_state_entered() -> void:
|
||||
emit_signal(\"state_changed\", \"walk\")
|
||||
|
||||
func _on_walking_state_physics_processing(_delta:float) -> void:
|
||||
if !_controlled_body.is_on_floor():
|
||||
_state_chart.call(\"send_event\", \"fall\")
|
||||
"
|
||||
|
||||
[node name="CharacterBody3D" type="CharacterBody3D" unique_id=513899147 node_paths=PackedStringArray("_mesh", "_animation_tree")]
|
||||
script = SubResource("GDScript_g15lx")
|
||||
_mesh = NodePath("Mixamo")
|
||||
_animation_tree = NodePath("AnimationTree")
|
||||
|
||||
[node name="Mixamo" parent="." unique_id=864303276 instance=ExtResource("1_2ddk3")]
|
||||
|
||||
[node name="Skeleton3D" parent="Mixamo/Armature" parent_id_path=PackedInt32Array(864303276, 440462832) index="0" unique_id=1320078933]
|
||||
bones/1/position = Vector3(0.04870448, 1.032008, 0.028295368)
|
||||
bones/1/rotation = Quaternion(0.0038603812, -0.042781625, -0.02686718, 0.9987157)
|
||||
bones/2/rotation = Quaternion(-0.07096221, 0.004199123, 0.015538491, 0.9973492)
|
||||
bones/3/rotation = Quaternion(0.018365402, 0.006404549, 0.027779015, 0.99942493)
|
||||
bones/4/rotation = Quaternion(0.03124219, 0.0067619453, 0.02769415, 0.99910533)
|
||||
bones/5/rotation = Quaternion(-0.09391238, 0.0024459476, 0.00025220038, 0.9955775)
|
||||
bones/6/position = Vector3(-9.210181e-09, 0.09341891, 0.028410409)
|
||||
bones/6/rotation = Quaternion(0.030966053, 0.013115423, -0.040265556, 0.99862295)
|
||||
bones/8/rotation = Quaternion(0.5692528, 0.50322324, -0.53913254, 0.36339208)
|
||||
bones/9/rotation = Quaternion(0.5071702, 0.2261647, 0.19236062, 0.80908924)
|
||||
bones/10/rotation = Quaternion(0.0002893699, -0.002175361, 0.13162343, 0.99129736)
|
||||
bones/11/rotation = Quaternion(-0.11637703, -0.15321882, 0.118520975, 0.97413206)
|
||||
bones/12/position = Vector3(-0.022598628, 0.0910931, 0.0051802346)
|
||||
bones/12/rotation = Quaternion(0.12757003, -0.06862957, -0.09849325, 0.984538)
|
||||
bones/13/rotation = Quaternion(0.11326781, 0.0038000888, -0.01111646, 0.9934951)
|
||||
bones/14/rotation = Quaternion(2.2009235e-06, -1.6751927e-07, -6.63283e-05, 1)
|
||||
bones/16/position = Vector3(-3.8366372e-07, 0.09533401, -4.4685564e-07)
|
||||
bones/16/rotation = Quaternion(0.09561433, -0.0127436975, -0.059153922, 0.99357754)
|
||||
bones/17/rotation = Quaternion(0.14413114, -2.6676324e-05, 0.0054576104, 0.98954356)
|
||||
bones/18/rotation = Quaternion(-4.040993e-06, -1.6275888e-07, 2.0526211e-05, 1)
|
||||
bones/20/position = Vector3(0.03806265, 0.08077777, 0.004868677)
|
||||
bones/20/rotation = Quaternion(0.2557746, 0.040497564, -0.06891092, 0.9634265)
|
||||
bones/21/rotation = Quaternion(0.15475252, -0.0008494721, 0.026853941, 0.98758787)
|
||||
bones/22/rotation = Quaternion(8.52236e-06, 5.516414e-07, -6.652472e-05, 1)
|
||||
bones/24/position = Vector3(0.01865083, 0.09104527, 0.0004301249)
|
||||
bones/24/rotation = Quaternion(0.19702755, 0.004634122, -0.056227524, 0.9787733)
|
||||
bones/25/rotation = Quaternion(0.12224227, -0.0012653368, 0.0022697877, 0.9924969)
|
||||
bones/26/rotation = Quaternion(-4.033557e-06, -2.9809286e-07, -6.354228e-07, 1)
|
||||
bones/28/position = Vector3(-0.026817447, 0.02466187, 0.015762206)
|
||||
bones/28/rotation = Quaternion(0.21899925, -0.11900992, 0.12523858, 0.96030796)
|
||||
bones/29/rotation = Quaternion(-0.05057509, 0.017804269, -0.10103139, 0.99343747)
|
||||
bones/30/rotation = Quaternion(-0.0015304416, 0.0007451259, -0.006073877, 0.99998015)
|
||||
bones/32/rotation = Quaternion(-0.5434131, 0.52665854, -0.54123205, -0.3666074)
|
||||
bones/33/rotation = Quaternion(0.49145934, -0.29928944, -0.17875111, 0.79808617)
|
||||
bones/34/position = Vector3(-9.903693e-08, 0.27841544, -1.116235e-07)
|
||||
bones/34/rotation = Quaternion(0.0002243128, 0.0015434523, -0.143857, 0.9895973)
|
||||
bones/35/position = Vector3(1.6371088e-07, 0.28328842, 1.3556392e-07)
|
||||
bones/35/rotation = Quaternion(-0.20313145, 0.2536574, -0.08786419, 0.9416345)
|
||||
bones/36/position = Vector3(0.022598363, 0.09108294, 0.005178664)
|
||||
bones/36/rotation = Quaternion(0.0982438, 0.060115937, 0.06501357, 0.9912152)
|
||||
bones/37/rotation = Quaternion(0.024330059, -0.0058166035, 0.0073140506, 0.9996603)
|
||||
bones/38/rotation = Quaternion(1.0574793e-05, -1.8729077e-07, -8.8072324e-05, 1)
|
||||
bones/40/position = Vector3(-2.4792166e-07, 0.095325135, 4.594313e-07)
|
||||
bones/40/rotation = Quaternion(0.11668334, 0.00690057, 0.053179618, 0.9917204)
|
||||
bones/41/rotation = Quaternion(0.08763589, 0.0004980627, -0.0029992005, 0.99614793)
|
||||
bones/42/rotation = Quaternion(2.0195055e-06, -1.5769648e-07, -0.00032192204, 0.99999994)
|
||||
bones/44/position = Vector3(-0.038062826, 0.08076688, 0.0048670825)
|
||||
bones/44/rotation = Quaternion(0.19296765, -0.0071753766, 0.033997346, 0.98058975)
|
||||
bones/45/rotation = Quaternion(0.10743011, 0.0074210684, -0.0354787, 0.99355173)
|
||||
bones/46/rotation = Quaternion(5.616749e-06, -2.462882e-07, -0.0004968697, 0.9999999)
|
||||
bones/48/position = Vector3(-0.018651353, 0.09103608, 0.00043070197)
|
||||
bones/48/rotation = Quaternion(0.17583169, 0.011183629, 0.033857506, 0.98377424)
|
||||
bones/49/rotation = Quaternion(0.080434814, 0.00278104, -0.004288758, 0.99674684)
|
||||
bones/50/rotation = Quaternion(2.066391e-06, -8.3535085e-08, -0.00011254099, 1)
|
||||
bones/52/position = Vector3(0.02681857, 0.02464834, 0.01573964)
|
||||
bones/52/rotation = Quaternion(0.20387587, 0.15056956, -0.11117494, 0.960939)
|
||||
bones/53/position = Vector3(3.5733688e-08, 0.041889846, -3.7099937e-08)
|
||||
bones/53/rotation = Quaternion(-0.041160505, -0.009343234, 0.13904583, 0.9893861)
|
||||
bones/54/position = Vector3(2.8207126e-10, 0.034163237, 1.5927924e-08)
|
||||
bones/54/rotation = Quaternion(-0.0016655411, -0.00080757204, 0.0069194976, 0.9999744)
|
||||
bones/56/rotation = Quaternion(0.023338497, 0.13932115, 0.98709935, -0.07536546)
|
||||
bones/57/rotation = Quaternion(-0.16320044, -0.00086023705, -0.004683052, 0.9865815)
|
||||
bones/58/rotation = Quaternion(0.42804745, -0.15841259, 0.038895346, 0.8889139)
|
||||
bones/59/rotation = Quaternion(0.33653727, -0.024077026, 0.023762424, 0.94106245)
|
||||
bones/61/rotation = Quaternion(-0.06063849, 0.031957228, 0.995892, -0.05916911)
|
||||
bones/62/rotation = Quaternion(-0.10745853, -0.00017616706, 0.0019304121, 0.9942077)
|
||||
bones/63/rotation = Quaternion(0.49414507, 0.08582836, -0.07049879, 0.8622553)
|
||||
bones/64/rotation = Quaternion(0.35782322, -0.007803631, 0.006070163, 0.933737)
|
||||
|
||||
[node name="AnimationTree" type="AnimationTree" parent="." unique_id=756651854]
|
||||
root_node = NodePath("../Mixamo")
|
||||
root_motion_track = NodePath("Armature/Skeleton3D:root")
|
||||
tree_root = SubResource("AnimationNodeStateMachine_fj36c")
|
||||
anim_player = NodePath("../Mixamo/AnimationPlayer")
|
||||
parameters/walk/blend_position = 0.0
|
||||
|
||||
[node name="CameraGimbalY" type="Node3D" parent="." unique_id=635211592]
|
||||
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0, 1, 0)
|
||||
script = SubResource("GDScript_vtyg2")
|
||||
camera_input_resource = ExtResource("2_vtyg2")
|
||||
|
||||
[node name="CameraGimbalX" type="Node3D" parent="CameraGimbalY" unique_id=1955443837]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.75, 0, 0)
|
||||
|
||||
[node name="SpringArm3D" type="SpringArm3D" parent="CameraGimbalY/CameraGimbalX" unique_id=627807718]
|
||||
spring_length = 2.0
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="CameraGimbalY/CameraGimbalX/SpringArm3D" unique_id=1672233531]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=1453410389]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
shape = SubResource("CapsuleShape3D_6ql8e")
|
||||
|
||||
[node name="MovementHandler" type="Node" parent="." unique_id=886399808]
|
||||
script = SubResource("GDScript_6ql8e")
|
||||
|
||||
[node name="StandardMovementChart" type="Node" parent="MovementHandler" unique_id=1972958997]
|
||||
script = ExtResource("1_wb1c3")
|
||||
metadata/_custom_type_script = "uid://couw105c3bde4"
|
||||
|
||||
[node name="Movement" type="Node" parent="MovementHandler/StandardMovementChart" unique_id=2027419101]
|
||||
script = ExtResource("3_2ddk3")
|
||||
initial_state = NodePath("Walking")
|
||||
|
||||
[node name="Walking" type="Node" parent="MovementHandler/StandardMovementChart/Movement" unique_id=262207346]
|
||||
script = ExtResource("4_baibx")
|
||||
|
||||
[node name="OnFall" type="Node" parent="MovementHandler/StandardMovementChart/Movement/Walking" unique_id=102593780]
|
||||
script = ExtResource("6_j3mgm")
|
||||
to = NodePath("../../Airborne/Falling")
|
||||
event = &"fall"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnJump" type="Node" parent="MovementHandler/StandardMovementChart/Movement/Walking" unique_id=1120626685]
|
||||
script = ExtResource("6_j3mgm")
|
||||
to = NodePath("../../Airborne/Jumping")
|
||||
event = &"jump"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="Airborne" type="Node" parent="MovementHandler/StandardMovementChart/Movement" unique_id=1974316951]
|
||||
script = ExtResource("3_2ddk3")
|
||||
initial_state = NodePath("CoyoteTime")
|
||||
|
||||
[node name="OnStopFalling" type="Node" parent="MovementHandler/StandardMovementChart/Movement/Airborne" unique_id=1177188765]
|
||||
script = ExtResource("6_j3mgm")
|
||||
to = NodePath("../../Walking")
|
||||
event = &"stop_falling"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="CoyoteTime" type="Node" parent="MovementHandler/StandardMovementChart/Movement/Airborne" unique_id=888564579]
|
||||
script = ExtResource("4_baibx")
|
||||
|
||||
[node name="OnCoyoteTimeJump" type="Node" parent="MovementHandler/StandardMovementChart/Movement/Airborne/CoyoteTime" unique_id=1777355782]
|
||||
script = ExtResource("6_j3mgm")
|
||||
to = NodePath("../../Jumping")
|
||||
event = &"jump"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnCoyoteTimeExpired" type="Node" parent="MovementHandler/StandardMovementChart/Movement/Airborne/CoyoteTime" unique_id=1678963496]
|
||||
script = ExtResource("6_j3mgm")
|
||||
to = NodePath("../../Falling")
|
||||
delay_in_seconds = "0.125"
|
||||
|
||||
[node name="Jumping" type="Node" parent="MovementHandler/StandardMovementChart/Movement/Airborne" unique_id=727713155]
|
||||
script = ExtResource("4_baibx")
|
||||
|
||||
[node name="OnStopJumping" type="Node" parent="MovementHandler/StandardMovementChart/Movement/Airborne/Jumping" unique_id=728514621]
|
||||
script = ExtResource("6_j3mgm")
|
||||
to = NodePath("../../CancelJump")
|
||||
event = &"stop_jumping"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="CancelJump" type="Node" parent="MovementHandler/StandardMovementChart/Movement/Airborne" unique_id=1518229692]
|
||||
script = ExtResource("4_baibx")
|
||||
|
||||
[node name="Falling" type="Node" parent="MovementHandler/StandardMovementChart/Movement/Airborne" unique_id=1731269645]
|
||||
script = ExtResource("4_baibx")
|
||||
|
||||
[node name="RootMotionView" type="RootMotionView" parent="." unique_id=345459633]
|
||||
animation_path = NodePath("../AnimationTree")
|
||||
|
||||
[connection signal="state_processing" from="MovementHandler/StandardMovementChart/Movement/Walking" to="." method="_on_walking_state_processing"]
|
||||
|
||||
[editable path="Mixamo"]
|
||||
Reference in New Issue
Block a user