crouch fixed
This commit is contained in:
parent
7bbeebdd2e
commit
276ff0252b
11 changed files with 167 additions and 115 deletions
|
|
@ -8,6 +8,7 @@
|
|||
[ext_resource type="Script" uid="uid://bmecgup3kcua7" path="res://scripts/weapon_system/weapon_system.gd" id="4_qlg0r"]
|
||||
[ext_resource type="Script" uid="uid://dd5mp72dq43v6" path="res://scripts/multiplayer/own_visibility_toggle.gd" id="4_smehm"]
|
||||
[ext_resource type="PackedScene" uid="uid://djwjl8xll53vn" path="res://scenes/weapons/starting_pistol.tscn" id="7_fjrip"]
|
||||
[ext_resource type="Script" uid="uid://7gmgcaxfh8sb" path="res://scripts/debug/property_shower.gd" id="7_oprun"]
|
||||
[ext_resource type="Script" uid="uid://3777rkbebgjm" path="res://scripts/state_machine/machine.gd" id="8_f1ej7"]
|
||||
[ext_resource type="PackedScene" uid="uid://c2r8dbudbs7l3" path="res://models/molikman_ingame.glb" id="8_smehm"]
|
||||
[ext_resource type="Script" uid="uid://bv8sgx78s8hwn" path="res://scripts/player/states/crouching.gd" id="9_oprun"]
|
||||
|
|
@ -16,94 +17,7 @@
|
|||
[ext_resource type="Script" uid="uid://cq4i0afwesdm3" path="res://scripts/player/states/falling.gd" id="12_fulsm"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_u8vuu"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_g2els"]
|
||||
resource_name = "Crouch"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("CollisionShape3D:shape:height")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [2.0, 1.5]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("CollisionShape3D:position")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, 1, 0), Vector3(0, 0.75, 0)]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("Camera3D:position")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, 2, 0), Vector3(0, 1.5, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_dqkch"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("CollisionShape3D:shape:height")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [2.0]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("CollisionShape3D:position")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, 1, 0)]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("Camera3D:position")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, 2, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_qhqgy"]
|
||||
resource_name = "Stand"
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_qlg0r"]
|
||||
_data = {
|
||||
&"Crouch": SubResource("Animation_g2els"),
|
||||
&"RESET": SubResource("Animation_dqkch"),
|
||||
&"Stand": SubResource("Animation_qhqgy")
|
||||
}
|
||||
resource_local_to_scene = true
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_g2els"]
|
||||
height = 1.2958984
|
||||
|
|
@ -118,12 +32,93 @@ properties/1/replication_mode = 1
|
|||
properties/2/path = NodePath("Camera3D:rotation")
|
||||
properties/2/spawn = true
|
||||
properties/2/replication_mode = 1
|
||||
properties/3/path = NodePath(".:crouched")
|
||||
properties/3/path = NodePath(".:hp")
|
||||
properties/3/spawn = true
|
||||
properties/3/replication_mode = 1
|
||||
properties/4/path = NodePath(".:hp")
|
||||
properties/4/spawn = true
|
||||
properties/4/replication_mode = 1
|
||||
|
||||
[sub_resource type="Animation" id="Animation_oprun"]
|
||||
resource_name = "crouch"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("CollisionShape3D:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, 1, 0), Vector3(0, 0.75, 0)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("CollisionShape3D:shape:height")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [2.0, 1.5]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("Camera3D:position")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, 2, 0), Vector3(0, 1.5, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_a8ls1"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("CollisionShape3D:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, 1, 0)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("CollisionShape3D:shape:height")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [2.0]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("Camera3D:position")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, 2, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_a8ls1"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_a8ls1"),
|
||||
&"crouch": SubResource("Animation_oprun")
|
||||
}
|
||||
|
||||
[node name="Player" type="CharacterBody3D"]
|
||||
collision_layer = 2
|
||||
|
|
@ -151,9 +146,6 @@ compensation_delay = 0.2
|
|||
[node name="molikman_hands" parent="Camera3D" instance=ExtResource("4_dqkch")]
|
||||
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0, -1, 0)
|
||||
|
||||
[node name="VisibleDisabler" type="Node" parent="Camera3D/molikman_hands"]
|
||||
script = ExtResource("4_smehm")
|
||||
|
||||
[node name="Skeleton3D" parent="Camera3D/molikman_hands/Hands" index="0"]
|
||||
bones/1/position = Vector3(0.16239367, 0.7620353, -0.22555673)
|
||||
bones/1/rotation = Quaternion(-0.013897974, 0.25458142, 0.93291974, 0.25427514)
|
||||
|
|
@ -216,16 +208,14 @@ bones/0/position = Vector3(-0.22279283, 0.7100338, -0.19202478)
|
|||
bones/0/rotation = Quaternion(-0.006717509, 0.6971531, 0.71686494, -0.0060944925)
|
||||
bones/1/position = Vector3(5.970651e-08, 0.06469957, 0.06380712)
|
||||
|
||||
[node name="VisibleDisabler" type="Node" parent="Camera3D/molikman_hands"]
|
||||
script = ExtResource("4_smehm")
|
||||
|
||||
[node name="RayCast3D" type="RayCast3D" parent="Camera3D"]
|
||||
target_position = Vector3(0, 0, -1000)
|
||||
collision_mask = 2
|
||||
script = ExtResource("4_fjrip")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_qlg0r")
|
||||
}
|
||||
|
||||
[node name="StandArea" type="Area3D" parent="."]
|
||||
collision_layer = 0
|
||||
|
||||
|
|
@ -243,6 +233,20 @@ anchor_bottom = 1.0
|
|||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="HUD"]
|
||||
layout_mode = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="HUD/PanelContainer"]
|
||||
layout_mode = 2
|
||||
script = ExtResource("7_oprun")
|
||||
property_array = Dictionary[NodePath, StringName]({
|
||||
NodePath("../../../BodyStateMachine"): &"current_state",
|
||||
NodePath("../../../WeaponSystem"): &"current_state",
|
||||
NodePath("../../../AnimationPlayer"): &"current_animation"
|
||||
})
|
||||
|
||||
[node name="Crosshair" type="Control" parent="HUD"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
|
|
@ -261,6 +265,9 @@ crosses_width = 2.0
|
|||
crosses_length = 6.0
|
||||
crosses_offset = 3.0
|
||||
|
||||
[node name="VisibleDisabler" type="Node" parent="HUD"]
|
||||
script = ExtResource("4_smehm")
|
||||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
replication_config = SubResource("SceneReplicationConfig_qhqgy")
|
||||
|
||||
|
|
@ -299,5 +306,10 @@ camera = NodePath("../Camera3D")
|
|||
[node name="Shoot" parent="WeaponSystem/StartingPistol" index="1" node_paths=PackedStringArray("raycast")]
|
||||
raycast = NodePath("../../../Camera3D/RayCast3D")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_a8ls1")
|
||||
}
|
||||
|
||||
[editable path="Camera3D/molikman_hands"]
|
||||
[editable path="WeaponSystem/StartingPistol"]
|
||||
|
|
|
|||
21
scripts/debug/property_shower.gd
Normal file
21
scripts/debug/property_shower.gd
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
extends VBoxContainer
|
||||
|
||||
@export var property_array: Dictionary[NodePath,StringName]
|
||||
|
||||
func _ready() -> void:
|
||||
for target in property_array.keys():
|
||||
var hbox = HBoxContainer.new()
|
||||
var name_label = Label.new()
|
||||
var splitted = property_array[target].split(":")
|
||||
name_label.text = splitted[len(splitted)-1]
|
||||
name_label.name = "Name"
|
||||
var value_label = Label.new()
|
||||
value_label.name = "Value"
|
||||
hbox.add_child(name_label,true)
|
||||
hbox.add_child(value_label,true)
|
||||
hbox.name = str(target).replace("/","_").replace(".","")
|
||||
add_child(hbox,true)
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
for target in property_array:
|
||||
get_node(str(target).replace("/","_").replace(".","")+"/Value").text = str(get_node(target).get(property_array[target]))
|
||||
1
scripts/debug/property_shower.gd.uid
Normal file
1
scripts/debug/property_shower.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://7gmgcaxfh8sb
|
||||
|
|
@ -8,10 +8,10 @@ extends State
|
|||
@export var crouch_time: float = 0.1
|
||||
|
||||
func enter() -> void:
|
||||
animation_player.play("Crouch",-1,1/crouch_time)
|
||||
animation_player.play("crouch",-1,1/crouch_time)
|
||||
|
||||
func exit() -> void:
|
||||
animation_player.play("Crouch",-1,-1/crouch_time,true)
|
||||
animation_player.play("crouch",-1,-1/crouch_time,true)
|
||||
|
||||
func physics_update(_delta: float) -> void:
|
||||
if not is_multiplayer_authority():
|
||||
|
|
@ -33,9 +33,7 @@ func physics_update(_delta: float) -> void:
|
|||
player.velocity.x = move_toward(player.velocity.x, 0, SPEED)
|
||||
player.velocity.z = move_toward(player.velocity.z, 0, SPEED)
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if not is_multiplayer_authority():
|
||||
return
|
||||
func state_input(event: InputEvent) -> void:
|
||||
if (toggle == true and event.is_action_pressed("plr_crouch")) or (toggle == false and event.is_action_released("plr_crouch")):
|
||||
if stand_up_area.has_overlapping_bodies() == false:
|
||||
transition.emit("Stand")
|
||||
|
|
|
|||
|
|
@ -31,10 +31,7 @@ func physics_update(_delta: float) -> void:
|
|||
player.velocity.x = move_toward(player.velocity.x, 0, SPEED)
|
||||
player.velocity.z = move_toward(player.velocity.z, 0, SPEED)
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if not is_multiplayer_authority():
|
||||
return
|
||||
|
||||
func state_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("plr_crouch"):
|
||||
transition.emit("Crouch")
|
||||
|
||||
|
|
|
|||
|
|
@ -31,9 +31,7 @@ func physics_update(_delta: float) -> void:
|
|||
player.velocity.x = move_toward(player.velocity.x, 0, SPEED)
|
||||
player.velocity.z = move_toward(player.velocity.z, 0, SPEED)
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if not is_multiplayer_authority():
|
||||
return
|
||||
func state_input(event: InputEvent) -> void:
|
||||
if event.is_action_released("plr_walk"):
|
||||
transition.emit("Stand")
|
||||
|
||||
|
|
|
|||
|
|
@ -9,17 +9,19 @@ func _ready() -> void:
|
|||
for child in get_children():
|
||||
if child is State:
|
||||
states[child.name] = child
|
||||
child.transition.connect(on_transition_required.rpc)
|
||||
child.transition.connect(on_transition_required)
|
||||
else:
|
||||
push_warning("Child of state machine is not state")
|
||||
|
||||
@rpc("authority","call_local","reliable")
|
||||
func on_transition_required(to: StringName):
|
||||
if is_multiplayer_authority() == false:
|
||||
return
|
||||
if states.has(to) == false:
|
||||
push_warning("Incorrect state request: " + to)
|
||||
return
|
||||
|
||||
change_state(states[to])
|
||||
change_state_to_name.rpc(to)
|
||||
|
||||
func change_state(to_state: State) -> void:
|
||||
if current_state != null:
|
||||
|
|
@ -27,6 +29,13 @@ func change_state(to_state: State) -> void:
|
|||
current_state = to_state
|
||||
current_state.enter()
|
||||
|
||||
@rpc
|
||||
func change_state_to_name(to_name: StringName):
|
||||
if current_state != null:
|
||||
current_state.exit()
|
||||
current_state = states[to_name]
|
||||
current_state.enter()
|
||||
|
||||
@rpc("authority","call_local","unreliable")
|
||||
func clear_state():
|
||||
if current_state == null:
|
||||
|
|
@ -39,6 +48,10 @@ func _process(delta: float) -> void:
|
|||
return
|
||||
current_state.update(delta)
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if current_state != null:
|
||||
current_state.state_input(event)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if current_state == null:
|
||||
return
|
||||
|
|
|
|||
|
|
@ -13,3 +13,5 @@ func update(delta: float) -> void:
|
|||
pass
|
||||
func physics_update(delta: float) -> void:
|
||||
pass
|
||||
func state_input(event: InputEvent) -> void:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -25,3 +25,10 @@ func _process(_delta: float) -> void:
|
|||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
pass
|
||||
|
||||
func _input(_event: InputEvent) -> void:
|
||||
pass
|
||||
|
||||
func state_input(event: InputEvent) -> void:
|
||||
if current_state != null:
|
||||
current_state.state_input(event)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ func enter() -> void:
|
|||
func exit() -> void:
|
||||
pass
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
func state_input(event: InputEvent) -> void:
|
||||
if not machine.is_multiplayer_authority(): return
|
||||
|
||||
if event.is_action_pressed("plr_reload"):
|
||||
|
|
|
|||
|
|
@ -84,6 +84,9 @@ func _physics_process(delta: float) -> void:
|
|||
func _input(event: InputEvent) -> void:
|
||||
if is_multiplayer_authority() == false: return
|
||||
|
||||
if current_state != null:
|
||||
current_state.state_input(event)
|
||||
|
||||
if event.is_action_pressed("plr_ult"):
|
||||
switch("ultimate")
|
||||
elif event.is_action_pressed("plr_bomb"):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue