From c1548e54512abdc53b3f91220d90508250906b0b Mon Sep 17 00:00:00 2001 From: Rendo Date: Wed, 3 Dec 2025 23:57:09 +0500 Subject: [PATCH] Fixed double-crouching --- scenes/molikman.tscn | 11 ++++------- scripts/player/states/falling.gd | 8 +++++++- scripts/player/states/standing.gd | 4 ---- scripts/player/states/walk.gd | 2 -- scripts/state_machine/machine.gd | 2 +- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/scenes/molikman.tscn b/scenes/molikman.tscn index c782b2f..1bc5391 100644 --- a/scenes/molikman.tscn +++ b/scenes/molikman.tscn @@ -7636,6 +7636,7 @@ weapon_models = { [node name="molikman_ingame" type="Node3D" parent="."] transform = Transform3D(0.75, 0, 0, 0, 0.74999994, 0, 0, 0, 0.74999994, 0, 1.1793717, 0) +visible = false [node name="Armature" type="Node3D" parent="molikman_ingame"] @@ -8106,10 +8107,6 @@ mesh = SubResource("ArrayMesh_aj0lc") skin = SubResource("Skin_53wat") surface_material_override/0 = ExtResource("26_r2jxp") -[node name="VisibleEnabler" type="Node" parent="molikman_ingame"] -script = ExtResource("4_smehm") -visible_for_others = true - [node name="CollisionShape3D" type="CollisionShape3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) shape = SubResource("CapsuleShape3D_u8vuu") @@ -8807,11 +8804,12 @@ player_movement = NodePath("../../PlayerMovement") player_input = NodePath("../../PlayerInput") weapon_system = NodePath("../../WeaponSystem") -[node name="Fall" type="Node" parent="BodyStateMachine" node_paths=PackedStringArray("player", "player_movement", "weapon_system", "land_sound")] +[node name="Fall" type="Node" parent="BodyStateMachine" node_paths=PackedStringArray("player", "player_movement", "player_input", "weapon_system", "land_sound")] script = ExtResource("12_fulsm") -acceleration = 25.0 player = NodePath("../..") player_movement = NodePath("../../PlayerMovement") +player_input = NodePath("../../PlayerInput") +acceleration = 25.0 weapon_system = NodePath("../../WeaponSystem") land_sound = NodePath("../../LandAudio") @@ -8872,7 +8870,6 @@ blue_team_texture = ExtResource("27_j3w78") replication_config = SubResource("SceneReplicationConfig_5amik") script = ExtResource("37_b2eak") -[connection signal="died" from="." to="molikman_ingame/VisibleEnabler" method="reverse"] [connection signal="died" from="." to="Camera3D" method="disable"] [connection signal="died" from="." to="Camera3D/DeadSpectator" method="set_active"] [connection signal="died" from="." to="BodyStateMachine/Death" method="on_death"] diff --git a/scripts/player/states/falling.gd b/scripts/player/states/falling.gd index 317fe1c..2b7750a 100644 --- a/scripts/player/states/falling.gd +++ b/scripts/player/states/falling.gd @@ -2,6 +2,7 @@ extends State @export var player: Player @export var player_movement: PlayerMovement +@export var player_input: PlayerInput @export var max_speed: float = 5.0 @export var acceleration: float @export var weapon_system: WeaponSystem @@ -18,7 +19,12 @@ func physics_update(delta: float) -> void: if not is_multiplayer_authority(): return if player.is_on_floor(): - transition.emit("Stand") + if player_input.compressed_states & PlayerInput.CROUCH: + transition.emit("Crouch") + elif player_input.compressed_states & PlayerInput.WALK: + transition.emit("Walk") + else: + transition.emit("Stand") land_sound.multiplayer_play() player.velocity += player.get_gravity() * delta diff --git a/scripts/player/states/standing.gd b/scripts/player/states/standing.gd index 7909b6c..31151a0 100644 --- a/scripts/player/states/standing.gd +++ b/scripts/player/states/standing.gd @@ -17,10 +17,6 @@ func enter() -> void: player_input.jumped.connect(on_jumped) player_input.crouch_begin.connect(begin_crouch) player_input.walk_begin.connect(begin_walk) - if player_input.compressed_states & PlayerInput.CROUCH: - begin_crouch() - elif player_input.compressed_states & PlayerInput.WALK: - begin_walk() func exit() -> void: player_input.jumped.disconnect(on_jumped) diff --git a/scripts/player/states/walk.gd b/scripts/player/states/walk.gd index ab99fd0..8d31be5 100644 --- a/scripts/player/states/walk.gd +++ b/scripts/player/states/walk.gd @@ -13,8 +13,6 @@ func enter() -> void: player_input.crouch_begin.connect(begin_crouch) player_input.walk_end.connect(end_walk) player_input.jumped.connect(on_jumped) - if player_input.compressed_states & PlayerInput.CROUCH: - begin_crouch() func exit() -> void: player_input.crouch_begin.disconnect(begin_crouch) diff --git a/scripts/state_machine/machine.gd b/scripts/state_machine/machine.gd index 1773c5a..bfcd0dd 100644 --- a/scripts/state_machine/machine.gd +++ b/scripts/state_machine/machine.gd @@ -31,7 +31,7 @@ func change_state(to_state: State) -> void: current_state = to_state current_state.enter() -@rpc +@rpc("authority","call_local","reliable") func change_state_to_name(to_name: StringName): if current_state != null: current_state.exit()