diff --git a/levels/prototype_scene.tscn b/levels/prototype_scene.tscn index 60c19e9..2f565c9 100644 --- a/levels/prototype_scene.tscn +++ b/levels/prototype_scene.tscn @@ -267,12 +267,12 @@ script = ExtResource("11_02ic3") exlusion_list = [NodePath("DefenceSpawn"), NodePath("AttackSpawn"), NodePath("SpectatorSpawn"), NodePath("MultiplayerSpawner")] [node name="DefenceSpawn" type="Marker3D" parent="PlayersContainer"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 37.170197, 0.5180037, -11.271502) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 37.170197, 0.5, -11.271502) script = ExtResource("10_02ic3") spawn_radius = 10.0 [node name="AttackSpawn" type="Marker3D" parent="PlayersContainer"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -31.553003, 0.5180037, 20.371899) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -31.553003, 0.49999988, 20.371899) script = ExtResource("10_02ic3") team = 1 spawn_radius = 5.0 diff --git a/players/player/states/standing.gd b/players/player/states/standing.gd index ef7a53f..8e2fb2b 100644 --- a/players/player/states/standing.gd +++ b/players/player/states/standing.gd @@ -14,9 +14,10 @@ extends State var step_time: float func _enter() -> void: - player_input.jumped.connect(on_jumped) - player_input.crouch_begin.connect(begin_crouch) - player_input.walk_begin.connect(begin_walk) + if Session.is_server_request(): + player_input.jumped.connect(on_jumped) + player_input.crouch_begin.connect(begin_crouch) + player_input.walk_begin.connect(begin_walk) func _exit() -> void: player_input.jumped.disconnect(on_jumped) diff --git a/systems/state_machine/machine.gd b/systems/state_machine/machine.gd index eb4a8d1..ab6b2ec 100644 --- a/systems/state_machine/machine.gd +++ b/systems/state_machine/machine.gd @@ -13,6 +13,8 @@ func _ready() -> void: else: push_warning("Child of state machine is not state") + await get_tree().process_frame + await get_tree().process_frame current_state.enter() func on_transition_required(to: StringName): diff --git a/systems/state_machine/substate_machine.gd b/systems/state_machine/substate_machine.gd index cc293ec..18b46b1 100644 --- a/systems/state_machine/substate_machine.gd +++ b/systems/state_machine/substate_machine.gd @@ -5,10 +5,11 @@ class_name SubStateMachine @export var enter_state: State func _enter() -> void: - change_state(enter_state) + if is_multiplayer_authority(): + change_state(enter_state) func _exit() -> void: - current_state.exit() + pass func update(delta: float) -> void: if current_state == null: diff --git a/systems/weapon_system/weapon_system.gd b/systems/weapon_system/weapon_system.gd index 4837fa1..b73be85 100644 --- a/systems/weapon_system/weapon_system.gd +++ b/systems/weapon_system/weapon_system.gd @@ -56,7 +56,10 @@ func add(state: WeaponSubStateMachine, slot: StringName) -> void: if current_state == null: current_state = state ammo_updated.emit(current_state.ammo,current_state.remaining_ammo) - state._enter.call_deferred() + #Replace with way to ensure all players loaded + await get_tree().process_frame + await get_tree().process_frame + state._enter() func process_spawned_weapon(weapon_node: Node): @@ -83,13 +86,13 @@ func switch(to: StringName, exit: bool = true): if slots.has(to) == false or slots[to] == null or slots[to] == current_state or (multiplayer.get_remote_sender_id() != 1 and is_multiplayer_authority() == false): return if current_state != null and exit: - current_state._exit() + current_state.exit() if current_state.can_be_previous: last_slot = slots.find_key(current_state) else: last_slot = "" current_state = slots[to] - current_state._enter() + current_state.enter() ammo_updated.emit(current_state.ammo,current_state.remaining_ammo) switched_to.emit(current_state) diff --git a/weapons/gun/intro_state.gd b/weapons/gun/intro_state.gd index 26f7768..cda16d4 100644 --- a/weapons/gun/intro_state.gd +++ b/weapons/gun/intro_state.gd @@ -3,10 +3,12 @@ extends WeaponState @export var emptyable: bool func _enter() -> void: + machine.animation_player.play(with_morphems("intro")) machine.animation_player.animation_finished.connect(on_animation_finished) func _exit() -> void: + machine.animation_player.animation_finished.disconnect(on_animation_finished) func on_animation_finished(animation): diff --git a/weapons/molikman/molik/molik.gd b/weapons/molikman/molik/molik.gd index e03189c..8143c75 100644 --- a/weapons/molikman/molik/molik.gd +++ b/weapons/molikman/molik/molik.gd @@ -1,12 +1,13 @@ -extends RigidBody3D +extends CharacterBody3D - -var contacts: int = 0 - -func _on_body_entered(_body: Node) -> void: - contacts += 1 - if contacts > 2: - var fire = preload("uid://l4t1mflutm3t").instantiate() +func _physics_process(delta: float) -> void: + + velocity += get_gravity() * delta + + if is_on_floor(): + var fire: Node3D = preload("res://weapons/molikman/molik/molikman_molotov_fire.tscn").instantiate() Session.dynamic_objects_parent.add_child(fire,true) fire.global_position = global_position queue_free() + + move_and_slide() diff --git a/weapons/molikman/molik/molik.tscn b/weapons/molikman/molik/molik.tscn index e546153..70fe10e 100644 --- a/weapons/molikman/molik/molik.tscn +++ b/weapons/molikman/molik/molik.tscn @@ -1,10 +1,7 @@ -[gd_scene load_steps=6 format=3 uid="uid://b6qahd6q60js7"] +[gd_scene load_steps=5 format=3 uid="uid://b6qahd6q60js7"] [ext_resource type="Script" uid="uid://y1s64ppporww" path="res://weapons/molikman/molik/molik.gd" id="1_aqokr"] -[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_aqokr"] -bounce = 0.53 - [sub_resource type="SphereMesh" id="SphereMesh_fwcyt"] radius = 0.05 height = 0.1 @@ -17,13 +14,8 @@ properties/0/path = NodePath(".:position") properties/0/spawn = true properties/0/replication_mode = 1 -[node name="Molik" type="RigidBody3D"] +[node name="Molik" type="CharacterBody3D"] collision_layer = 8 -physics_material_override = SubResource("PhysicsMaterial_aqokr") -gravity_scale = 0.25 -continuous_cd = true -contact_monitor = true -max_contacts_reported = 2 script = ExtResource("1_aqokr") [node name="MeshInstance3D" type="MeshInstance3D" parent="."] @@ -34,5 +26,3 @@ shape = SubResource("SphereShape3D_aqokr") [node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."] replication_config = SubResource("SceneReplicationConfig_6ic6f") - -[connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/weapons/molikman/molik/throw.gd b/weapons/molikman/molik/throw.gd index b959d78..f6a9e91 100644 --- a/weapons/molikman/molik/throw.gd +++ b/weapons/molikman/molik/throw.gd @@ -22,7 +22,7 @@ func fire() -> void: machine.animation_player.play(machine.animation_prefix + "shoot") if is_multiplayer_authority(): - var molotov: RigidBody3D = molik.instantiate() + var molotov: CharacterBody3D = molik.instantiate() Session.dynamic_objects_parent.add_child(molotov,true) molotov.global_transform = machine.player_camera.global_transform - molotov.apply_impulse(-molotov.global_basis.z * 10) + molotov.velocity = -molotov.global_basis.z * 100