diff --git a/.godot/editor/filesystem_update4 b/.godot/editor/filesystem_update4 index cd834bc..480b3ca 100644 --- a/.godot/editor/filesystem_update4 +++ b/.godot/editor/filesystem_update4 @@ -1,2 +1,6 @@ res://level/scripts/player.gd res://level/scripts/spring_arm_offset.gd +res://level/scripts/level.gd +res://level/scripts/3d_godot_robot.gd +res://level/scenes/player.tscn +res://README.md diff --git a/.godot/editor/player.tscn-editstate-8297c267175990df8d531cedde7634f8.cfg b/.godot/editor/player.tscn-editstate-8297c267175990df8d531cedde7634f8.cfg index 45da82b..8db2369 100644 --- a/.godot/editor/player.tscn-editstate-8297c267175990df8d531cedde7634f8.cfg +++ b/.godot/editor/player.tscn-editstate-8297c267175990df8d531cedde7634f8.cfg @@ -1,7 +1,16 @@ [editor_states] Anim={ -"visible": false +"animation": "Attack1", +"player": NodePath("3DGodotRobot/AnimationPlayer"), +"track_editor_state": { +"fps_compat": true, +"fps_mode": false, +"offset": 0.0, +"v_scroll": 170.0, +"zoom": 1.0 +}, +"visible": true } 2D={ "grid_offset": Vector2(0, 0), @@ -187,4 +196,4 @@ Anim={ "zfar": 4000.01, "znear": 0.05 } -selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@20438/@Panel@14/@VBoxContainer@15/DockHSplitLeftL/DockHSplitLeftR/DockHSplitMain/@VBoxContainer@26/DockVSplitCenter/@VSplitContainer@62/@VBoxContainer@63/@EditorMainScreen@103/MainScreen/@CanvasItemEditor@10871/@VSplitContainer@10516/@HSplitContainer@10518/@HSplitContainer@10520/@Control@10521/@SubViewportContainer@10522/@SubViewport@10523/Player/3DGodotRobot/RobotArmature/Skeleton3D/Face/MeshInstance3D")]) +selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@20438/@Panel@14/@VBoxContainer@15/DockHSplitLeftL/DockHSplitLeftR/DockHSplitMain/@VBoxContainer@26/DockVSplitCenter/@VSplitContainer@62/@VBoxContainer@63/@EditorMainScreen@103/MainScreen/@CanvasItemEditor@10871/@VSplitContainer@10516/@HSplitContainer@10518/@HSplitContainer@10520/@Control@10521/@SubViewportContainer@10522/@SubViewport@10523/Player/3DGodotRobot/AnimationPlayer")]) diff --git a/README.md b/README.md index 2067325..6afb228 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # SurvivalOfTheSnippest -MultiplayerFighter \ No newline at end of file +MultiplayerFighter diff --git a/level/scenes/player.tscn b/level/scenes/player.tscn index f3ab457..7b9e07e 100644 --- a/level/scenes/player.tscn +++ b/level/scenes/player.tscn @@ -456,7 +456,6 @@ resource_local_to_scene = true [sub_resource type="Animation" id="Animation_jou0i"] resource_name = "Attack1" length = 1.20833 -loop_mode = 1 tracks/0/type = "position_3d" tracks/0/imported = true tracks/0/enabled = true @@ -4811,14 +4810,14 @@ bones/0/parent = -1 bones/0/rest = Transform3D(1, 9.10383e-15, 2.38419e-07, 7.10847e-09, 0.999555, -0.0298151, -2.38313e-07, 0.0298151, 0.999556, 8.26265e-18, 0.90683, 0.0298551) bones/0/enabled = true bones/0/position = Vector3(-3.5256e-16, 0.861288, 0.0298551) -bones/0/rotation = Quaternion(0.0149092, 1.19196e-07, 1.77731e-09, 0.999889) +bones/0/rotation = Quaternion(0.014909198, 1.1919598e-07, 1.7773096e-09, 0.99988884) bones/0/scale = Vector3(1, 1, 1) bones/1/name = "spine.001" bones/1/parent = 0 bones/1/rest = Transform3D(1, -1.40362e-08, 4.13501e-10, 1.40362e-08, 0.998266, -0.0588722, 4.13562e-10, 0.0588722, 0.998266, -3.15279e-15, 0.264173, 5.80784e-09) bones/1/enabled = true bones/1/position = Vector3(-3.15279e-15, 0.264173, 5.80784e-09) -bones/1/rotation = Quaternion(0.0294489, -1.52182e-14, 7.02117e-09, 0.999566) +bones/1/rotation = Quaternion(0.029448908, -1.5218204e-14, 7.0211716e-09, 0.9995663) bones/1/scale = Vector3(1, 1, 1) bones/2/name = "spine.002" bones/2/parent = 1 @@ -4839,14 +4838,14 @@ bones/4/parent = 3 bones/4/rest = Transform3D(1, 6.66134e-16, -2.38419e-07, -2.57501e-09, 0.999942, -0.0108004, 2.38405e-07, 0.0108004, 0.999942, -2.88374e-16, 0.176079, -0.0108779) bones/4/enabled = true bones/4/position = Vector3(-3.65722e-16, 0.151501, -0.011741) -bones/4/rotation = Quaternion(0.00540027, -1.19208e-07, -6.43763e-10, 0.999986) +bones/4/rotation = Quaternion(0.005400273, -1.1920807e-07, -6.4376326e-10, 0.9999855) bones/4/scale = Vector3(1, 1, 1) bones/5/name = "Head" bones/5/parent = 4 bones/5/rest = Transform3D(1, 3.91584e-09, -3.22583e-11, -3.91584e-09, 0.999865, -0.0164242, -3.20606e-11, 0.0164242, 0.999865, -8.70283e-16, 0.138682, 3.72529e-09) bones/5/enabled = true bones/5/position = Vector3(-8.70283e-16, 0.138682, 3.72529e-09) -bones/5/rotation = Quaternion(0.00821238, -4.9429e-14, -1.95798e-09, 0.999966) +bones/5/rotation = Quaternion(0.008212383, -4.9429028e-14, -1.9579807e-09, 0.99996626) bones/5/scale = Vector3(1, 1, 1) bones/6/name = "HeadTop" bones/6/parent = 5 @@ -4860,91 +4859,91 @@ bones/7/parent = 5 bones/7/rest = Transform3D(1, 1.87855e-09, 2.38411e-07, 0, 0.999969, -0.00787921, -2.38419e-07, 0.00787921, 0.999969, 7.44409e-08, 0.540609, 0.312228) bones/7/enabled = true bones/7/position = Vector3(7.44409e-08, 0.540609, 0.312228) -bones/7/rotation = Quaternion(0.00393964, 1.19208e-07, -4.69641e-10, 0.999992) +bones/7/rotation = Quaternion(0.0039396407, 1.1920803e-07, -4.696411e-10, 0.99999225) bones/7/scale = Vector3(1, 1, 1) bones/8/name = "Chin" bones/8/parent = 5 bones/8/rest = Transform3D(1, 1.87855e-09, 2.38411e-07, 0, 0.999969, -0.00787921, -2.38419e-07, 0.00787921, 0.999969, 9.98369e-08, 0.0857493, 0.418746) bones/8/enabled = true bones/8/position = Vector3(9.97907e-08, 0.0611572, 0.418552) -bones/8/rotation = Quaternion(0.00393964, 1.19208e-07, -4.69641e-10, 0.999992) +bones/8/rotation = Quaternion(0.0039396407, 1.1920803e-07, -4.696411e-10, 0.99999225) bones/8/scale = Vector3(1, 1, 1) bones/9/name = "shoulder.L" bones/9/parent = 3 bones/9/rest = Transform3D(0.0360757, 0.999142, 0.0203239, -0.0345019, -0.0190798, 0.999223, 0.998753, -0.0367489, 0.0337839, 0.267321, 0.0764983, -0.028224) bones/9/enabled = true bones/9/position = Vector3(0.267321, 0.0764983, -0.028224) -bones/9/rotation = Quaternion(-0.523067, -0.457802, -0.521926, 0.49438) +bones/9/rotation = Quaternion(-0.523067, -0.45780203, -0.521926, 0.49438003) bones/9/scale = Vector3(1, 1, 1) bones/10/name = "upper_arm.L" bones/10/parent = 9 bones/10/rest = Transform3D(-0.106441, 0.0606935, 0.992465, -0.00297219, 0.998111, -0.0613576, -0.994315, -0.00948077, -0.10606, 0.00943596, 0.223043, -8.37785e-05) bones/10/enabled = true bones/10/position = Vector3(0.00943596, 0.223043, -8.37785e-05) -bones/10/rotation = Quaternion(-0.356441, 0.617847, -0.433107, 0.551029) +bones/10/rotation = Quaternion(-0.35644102, 0.6178471, -0.43310705, 0.55102915) bones/10/scale = Vector3(1, 1, 1) bones/11/name = "forearm.L" bones/11/parent = 10 bones/11/rest = Transform3D(0.98184, -0.0507598, -0.182795, 0.0571828, 0.997912, 0.0300364, 0.180889, -0.0399437, 0.982692, -1.57789e-07, 0.280382, -1.0906e-08) bones/11/enabled = true bones/11/position = Vector3(-1.57789e-07, 0.280382, -1.0906e-08) -bones/11/rotation = Quaternion(-0.0175777, -0.091351, 0.0271132, 0.995294) +bones/11/rotation = Quaternion(-0.017577708, -0.09135104, 0.027113209, 0.9952944) bones/11/scale = Vector3(1, 1, 1) bones/12/name = "hand.L" bones/12/parent = 11 bones/12/rest = Transform3D(0.998796, 0.0360371, 0.0332857, -0.0346117, 0.998499, -0.0424496, -0.0347655, 0.0412464, 0.998544, -3.72351e-07, 0.225629, 2.17875e-08) bones/12/enabled = true bones/12/position = Vector3(-3.72351e-07, 0.225629, 2.17875e-08) -bones/12/rotation = Quaternion(0.0209349, 0.0170217, -0.0176714, 0.99948) +bones/12/rotation = Quaternion(0.020934893, 0.017021695, -0.017671395, 0.9994797) bones/12/scale = Vector3(1, 1, 1) bones/13/name = "shoulder.R" bones/13/parent = 3 bones/13/rest = Transform3D(0.0360757, -0.999142, -0.0203239, 0.0345019, -0.0190798, 0.999223, -0.998753, -0.0367489, 0.0337839, -0.267321, 0.0764983, -0.028224) bones/13/enabled = true bones/13/position = Vector3(-0.267321, 0.0764983, -0.028224) -bones/13/rotation = Quaternion(-0.523067, 0.457802, 0.521926, 0.49438) +bones/13/rotation = Quaternion(-0.523067, 0.45780203, 0.521926, 0.49438003) bones/13/scale = Vector3(1, 1, 1) bones/14/name = "upper_arm.R" bones/14/parent = 13 bones/14/rest = Transform3D(-0.106441, -0.0606935, -0.992465, 0.00297219, 0.998111, -0.0613576, 0.994315, -0.00948077, -0.10606, -0.00943596, 0.223043, -8.37785e-05) bones/14/enabled = true bones/14/position = Vector3(-0.00943596, 0.223043, -8.37785e-05) -bones/14/rotation = Quaternion(-0.356441, -0.617847, 0.433107, 0.551029) +bones/14/rotation = Quaternion(-0.35644102, -0.6178471, 0.43310705, 0.55102915) bones/14/scale = Vector3(1, 1, 1) bones/15/name = "forearm.R" bones/15/parent = 14 bones/15/rest = Transform3D(0.98184, 0.0507598, 0.182795, -0.0571828, 0.997912, 0.0300364, -0.180889, -0.0399437, 0.982692, 1.57789e-07, 0.280382, -1.0906e-08) bones/15/enabled = true bones/15/position = Vector3(1.57789e-07, 0.280382, -1.0906e-08) -bones/15/rotation = Quaternion(-0.0175777, 0.091351, -0.0271132, 0.995294) +bones/15/rotation = Quaternion(-0.017577708, 0.09135104, -0.027113209, 0.9952944) bones/15/scale = Vector3(1, 1, 1) bones/16/name = "hand.R" bones/16/parent = 15 bones/16/rest = Transform3D(0.998796, -0.0360371, -0.0332857, 0.0346117, 0.998499, -0.0424496, 0.0347655, 0.0412464, 0.998544, 3.72351e-07, 0.225629, 2.17875e-08) bones/16/enabled = true bones/16/position = Vector3(3.72351e-07, 0.225629, 2.17875e-08) -bones/16/rotation = Quaternion(0.0209349, -0.0170217, 0.0176714, 0.99948) +bones/16/rotation = Quaternion(0.020934893, -0.017021695, 0.017671395, 0.9994797) bones/16/scale = Vector3(1, 1, 1) bones/17/name = "thigh.L" bones/17/parent = 0 bones/17/rest = Transform3D(0.999169, 0.0422695, -0.00959818, 0.0419598, -0.998643, -0.0308697, -0.0108906, 0.0304362, -0.999534, 0.276084, 0.0659952, -0.00346868) bones/17/enabled = true bones/17/position = Vector3(0.276084, 0.0659952, -0.00346868) -bones/17/rotation = Quaternion(0.991415, 0.0203396, -0.00748625, 0.128945) +bones/17/rotation = Quaternion(0.9914149, 0.020339603, -0.0074862493, 0.12894498) bones/17/scale = Vector3(1.00011, 1, 1.00006) bones/18/name = "shin.L" bones/18/parent = 17 bones/18/rest = Transform3D(0.998494, -0.0540184, 0.00956905, 0.0538958, 0.998466, 0.012631, -0.0102367, -0.0120962, 0.999874, -5.17625e-09, 0.374795, -3.10704e-09) bones/18/enabled = true bones/18/position = Vector3(-5.17625e-09, 0.374795, -3.10704e-09) -bones/18/rotation = Quaternion(0.249628, 0.00871771, 0.024974, 0.967981) +bones/18/rotation = Quaternion(0.24962787, 0.008717706, 0.024973989, 0.9679805) bones/18/scale = Vector3(1, 1, 1) bones/19/name = "foot.L" bones/19/parent = 18 bones/19/rest = Transform3D(0.999932, 0.00648757, 0.00970069, -0.0116559, 0.514227, 0.857575, 0.000575222, -0.85763, 0.514268, 8.31179e-09, 0.334457, -5.94341e-09) bones/19/enabled = true bones/19/position = Vector3(8.31179e-09, 0.334457, -5.94341e-09) -bones/19/rotation = Quaternion(-0.608714, 0.00331542, -0.00479121, 0.793369) +bones/19/rotation = Quaternion(-0.60871375, 0.0033154185, -0.004791208, 0.7933686) bones/19/scale = Vector3(1, 1, 1) bones/20/name = "toe.L" bones/20/parent = 19 @@ -4958,21 +4957,21 @@ bones/21/parent = 0 bones/21/rest = Transform3D(0.999168, -0.0422695, 0.00959819, -0.0419598, -0.998643, -0.0308697, 0.0108906, 0.0304362, -0.999534, -0.276084, 0.0659953, -0.00346881) bones/21/enabled = true bones/21/position = Vector3(-0.276084, 0.0659953, -0.00346881) -bones/21/rotation = Quaternion(0.991415, -0.0203396, 0.00748626, 0.128945) +bones/21/rotation = Quaternion(0.9914149, -0.020339599, 0.0074862596, 0.12894498) bones/21/scale = Vector3(1.00011, 1, 1.00006) bones/22/name = "shin.R" bones/22/parent = 21 bones/22/rest = Transform3D(0.998494, 0.0540184, -0.00956902, -0.0538959, 0.998467, 0.012631, 0.0102367, -0.0120963, 0.999875, -4.78381e-09, 0.374795, -3.10751e-09) bones/22/enabled = true bones/22/position = Vector3(-4.78381e-09, 0.374795, -3.10751e-09) -bones/22/rotation = Quaternion(0.249628, -0.00871765, -0.0249741, 0.96798) +bones/22/rotation = Quaternion(0.24962787, -0.008717654, -0.024974087, 0.96798044) bones/22/scale = Vector3(1, 1, 1) bones/23/name = "foot.R" bones/23/parent = 22 bones/23/rest = Transform3D(0.999932, -0.00648758, -0.0097007, 0.011656, 0.514227, 0.857575, -0.000575223, -0.85763, 0.514267, 2.49345e-08, 0.334457, -1.36528e-08) bones/23/enabled = true bones/23/position = Vector3(2.49345e-08, 0.334457, -1.36528e-08) -bones/23/rotation = Quaternion(-0.608714, -0.00331544, 0.00479126, 0.793369) +bones/23/rotation = Quaternion(-0.60871375, -0.0033154383, 0.004791258, 0.7933686) bones/23/scale = Vector3(1, 1, 1) bones/24/name = "toe.R" bones/24/parent = 23 diff --git a/level/scripts/3d_godot_robot.gd b/level/scripts/3d_godot_robot.gd index 595b269..952fbe6 100644 --- a/level/scripts/3d_godot_robot.gd +++ b/level/scripts/3d_godot_robot.gd @@ -14,6 +14,10 @@ func apply_rotation(_velocity: Vector3) -> void: # rpc("sync_player_rotation", new_rotation_y) func animate(_velocity: Vector3) -> void: + # Don't override attack animation if it's playing + if animation_player.is_playing() and animation_player.current_animation == "Attack1": + return + if not _character.is_on_floor(): if _velocity.y < 0: animation_player.play("Fall") @@ -31,6 +35,13 @@ func animate(_velocity: Vector3) -> void: animation_player.play("Idle") +func play_attack() -> void: + if animation_player: + # Play attack animation once (don't loop) + animation_player.play("Attack1", -1, 1.0) + # Ensure it doesn't loop + animation_player.animation_set_next("Attack1", "") + # @rpc("any_peer", "reliable") # func sync_player_rotation(rotation_y: float) -> void: # rotation.y = rotation_y diff --git a/level/scripts/level.gd b/level/scripts/level.gd index 0445f32..74b9e04 100644 --- a/level/scripts/level.gd +++ b/level/scripts/level.gd @@ -5,6 +5,7 @@ extends Node3D @onready var address_input: LineEdit = $Menu/MainContainer/MainMenu/Option3/AddressInput @onready var players_container: Node3D = $PlayersContainer @onready var menu: Control = $Menu +@onready var main_menu: VBoxContainer = $Menu/MainContainer/MainMenu @export var player_scene: PackedScene # multiplayer chat @@ -19,6 +20,10 @@ func _ready(): multiplayer_chat.hide() menu.show() multiplayer_chat.set_process_input(true) + + # Add quick-fill preset buttons + _create_preset_buttons() + if not multiplayer.is_server(): return @@ -121,3 +126,39 @@ func _on_send_pressed() -> void: @rpc("any_peer", "call_local") func msg_rpc(nick, msg): chat.text += str(nick, " : ", msg, "\n") + +# ---------- PRESET BUTTONS ---------- +func _create_preset_buttons(): + # Create a container for preset buttons + var preset_container = HBoxContainer.new() + preset_container.name = "PresetContainer" + + var preset_label = Label.new() + preset_label.text = "Quick Fill:" + preset_container.add_child(preset_label) + + # Scott button + var scott_button = Button.new() + scott_button.text = "Scott" + scott_button.pressed.connect(_on_scott_preset) + preset_container.add_child(scott_button) + + # Jemz button + var jemz_button = Button.new() + jemz_button.text = "Jemz" + jemz_button.pressed.connect(_on_jemz_preset) + preset_container.add_child(jemz_button) + + # Add to main menu at the top + main_menu.add_child(preset_container) + main_menu.move_child(preset_container, 0) + +func _on_scott_preset(): + nick_input.text = "Scott" + skin_input.text = "Blue" + address_input.text = "127.0.0.1" + +func _on_jemz_preset(): + nick_input.text = "Jemz" + skin_input.text = "Red" + address_input.text = "127.0.0.1" diff --git a/level/scripts/player.gd b/level/scripts/player.gd index 54f4ded..fc630ae 100644 --- a/level/scripts/player.gd +++ b/level/scripts/player.gd @@ -179,8 +179,16 @@ func _perform_attack(): if not is_multiplayer_authority() or is_dead: return + # Don't attack if already attacking + if _body and _body.animation_player and _body.animation_player.current_animation == "Attack1": + return + _attack_timer = attack_cooldown + # Play attack animation once + if _body: + _body.play_attack() + # Find nearest enemy in range var space_state = get_world_3d().direct_space_state var query = PhysicsShapeQueryParameters3D.new()