Compare commits

..

2 Commits

Author SHA1 Message Date
Twirpytherobot 2ec7d56511 Sword animations now sync 2 weeks ago
Twirpytherobot b1f1016475 Applecorer 2 weeks ago
  1. BIN
      assets/Objects/Applecorer.glb
  2. 16
      level/resources/weapon_applecorer.tres
  3. 10
      level/scenes/Player_Lilguy.tscn
  4. 10
      level/scenes/level.tscn
  5. 8
      level/scenes/weapons/Applecoremesh.tscn
  6. 17
      level/scenes/weapons/world_weapon_applecorer.tscn
  7. 7
      level/scripts/base_weapon.gd
  8. 15
      level/scripts/lilguy_body.gd
  9. 12
      level/scripts/player.gd

Binary file not shown.

@ -0,0 +1,16 @@
[gd_resource type="Resource" script_class="WeaponData" load_steps=3 format=3 uid="uid://b2q62xc0jw4w3"]
[ext_resource type="PackedScene" uid="uid://cehc5ckhq2byd" path="res://level/scenes/weapons/Applecoremesh.tscn" id="1_1ytxi"]
[ext_resource type="Script" uid="uid://d2homvlmrg6xs" path="res://level/scripts/weapon_data.gd" id="2_hfi3c"]
[resource]
script = ExtResource("2_hfi3c")
weapon_name = "Apple Sword"
description = "yum"
damage = 20.0
attack_range = 3.5
attack_cooldown = 0.6
attack_animation = "Attack_TwoHandSwing"
knockback_force = 12.0
mesh_scene = ExtResource("1_1ytxi")
weight = 2.0

@ -1,7 +1,7 @@
[gd_scene load_steps=7 format=3 uid="uid://db06e8q8f8bdq"] [gd_scene load_steps=7 format=3 uid="uid://db06e8q8f8bdq"]
[ext_resource type="Script" uid="uid://c2si8gkbnde0c" path="res://level/scripts/player.gd" id="1_player"] [ext_resource type="Script" uid="uid://c2si8gkbnde0c" path="res://level/scripts/player.gd" id="1_player"]
[ext_resource type="PackedScene" uid="uid://byw3ig2bs1wgu" path="res://assets/characters/player/LilguyRigged.glb" id="2_lilguy"] [ext_resource type="PackedScene" uid="uid://b22ou40sbkavj" path="res://assets/characters/player/LilguyRigged.glb" id="2_lilguy"]
[ext_resource type="Script" uid="uid://cf7jky1bcs560" path="res://level/scripts/lilguy_body.gd" id="3_body"] [ext_resource type="Script" uid="uid://cf7jky1bcs560" path="res://level/scripts/lilguy_body.gd" id="3_body"]
[ext_resource type="Script" uid="uid://bj7yrijm7bppq" path="res://level/scripts/spring_arm_offset.gd" id="4_spring"] [ext_resource type="Script" uid="uid://bj7yrijm7bppq" path="res://level/scripts/spring_arm_offset.gd" id="4_spring"]
@ -24,8 +24,8 @@ properties/3/spawn = true
properties/3/replication_mode = 1 properties/3/replication_mode = 1
[node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("_body", "_spring_arm_offset", "_weapon_attachment", "_weapon_container", "_offhand_attachment", "_offhand_container")] [node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("_body", "_spring_arm_offset", "_weapon_attachment", "_weapon_container", "_offhand_attachment", "_offhand_container")]
script = ExtResource("1_player")
collision_mask = 3 collision_mask = 3
script = ExtResource("1_player")
_body = NodePath("LilguyRigged/Armature") _body = NodePath("LilguyRigged/Armature")
_spring_arm_offset = NodePath("SpringArmOffset") _spring_arm_offset = NodePath("SpringArmOffset")
_weapon_attachment = NodePath("LilguyRigged/Armature/Skeleton3D/WeaponPoint") _weapon_attachment = NodePath("LilguyRigged/Armature/Skeleton3D/WeaponPoint")
@ -93,7 +93,7 @@ transform = Transform3D(-0.43292555, -0.61284775, 0.6610542, 0.7782953, 0.115858
bone_name = "mixamorig_RightHand" bone_name = "mixamorig_RightHand"
bone_idx = 14 bone_idx = 14
[node name="WeaponContainer" type="Node3D" parent="LilguyRigged/Armature/Skeleton3D/WeaponPoint" index="0"] [node name="WeaponContainer" type="Node3D" parent="LilguyRigged/Armature/Skeleton3D/WeaponPoint"]
transform = Transform3D(36.6912, 297.2667, 16.921356, 46.72698, 11.0892515, -296.13126, -294.05847, 38.85366, -44.94499, 24.08223, -7.4241333, 7.098694) transform = Transform3D(36.6912, 297.2667, 16.921356, 46.72698, 11.0892515, -296.13126, -294.05847, 38.85366, -44.94499, 24.08223, -7.4241333, 7.098694)
[node name="OffhandPoint" type="BoneAttachment3D" parent="LilguyRigged/Armature/Skeleton3D" index="2"] [node name="OffhandPoint" type="BoneAttachment3D" parent="LilguyRigged/Armature/Skeleton3D" index="2"]
@ -101,7 +101,7 @@ transform = Transform3D(0.6212382, -0.004605584, -0.7836083, -0.620316, 0.608137
bone_name = "mixamorig_LeftHand" bone_name = "mixamorig_LeftHand"
bone_idx = 10 bone_idx = 10
[node name="OffhandContainer" type="Node3D" parent="LilguyRigged/Armature/Skeleton3D/OffhandPoint" index="0"] [node name="OffhandContainer" type="Node3D" parent="LilguyRigged/Armature/Skeleton3D/OffhandPoint"]
transform = Transform3D(-17.74905, -295.46814, -48.82108, 21.019196, -50.01525, 295.05362, -298.73593, 14.035805, 23.660797, 0.005859375, 0.39337158, 0.06616211) transform = Transform3D(-17.74905, -295.46814, -48.82108, 21.019196, -50.01525, 295.05362, -298.73593, 14.035805, 23.660797, 0.005859375, 0.39337158, 0.06616211)
[node name="CollisionShape3D" type="CollisionShape3D" parent="."] [node name="CollisionShape3D" type="CollisionShape3D" parent="."]
@ -130,3 +130,5 @@ text = "player name test"
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."] [node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
replication_config = SubResource("SceneReplicationConfig_xbohm") replication_config = SubResource("SceneReplicationConfig_xbohm")
[editable path="LilguyRigged"]

@ -1,10 +1,11 @@
[gd_scene load_steps=19 format=3 uid="uid://dugaivbj1o66n"] [gd_scene load_steps=20 format=3 uid="uid://dugaivbj1o66n"]
[ext_resource type="Script" uid="uid://d0dgljwwl463n" path="res://level/scripts/level.gd" id="1_e1sh7"] [ext_resource type="Script" uid="uid://d0dgljwwl463n" path="res://level/scripts/level.gd" id="1_e1sh7"]
[ext_resource type="PackedScene" uid="uid://db06e8q8f8bdq" path="res://level/scenes/Player_Lilguy.tscn" id="1_uvcbi"] [ext_resource type="PackedScene" uid="uid://db06e8q8f8bdq" path="res://level/scenes/Player_Lilguy.tscn" id="1_uvcbi"]
[ext_resource type="FontFile" uid="uid://diapabmalpcrj" path="res://assets/fonts/Kurland.ttf" id="3_icc4p"] [ext_resource type="FontFile" uid="uid://wipqjhfqeuwd" path="res://assets/fonts/Kurland.ttf" id="3_icc4p"]
[ext_resource type="PackedScene" uid="uid://b48oxbcgxu3d8" path="res://assets/Objects/Colosseum_10.fbx" id="4_u750a"] [ext_resource type="PackedScene" uid="uid://chkrcwlprbn88" path="res://assets/Objects/Colosseum_10.fbx" id="4_u750a"]
[ext_resource type="PackedScene" uid="uid://hd6pq287rgye" path="res://level/scenes/weapons/world_weapon_testsword.tscn" id="5_cwx4m"] [ext_resource type="PackedScene" uid="uid://hd6pq287rgye" path="res://level/scenes/weapons/world_weapon_testsword.tscn" id="5_cwx4m"]
[ext_resource type="PackedScene" uid="uid://8c4l6s6x67vh" path="res://level/scenes/weapons/world_weapon_applecorer.tscn" id="6_xerh7"]
[sub_resource type="PlaneMesh" id="PlaneMesh_r5xs5"] [sub_resource type="PlaneMesh" id="PlaneMesh_r5xs5"]
size = Vector2(90, 90) size = Vector2(90, 90)
@ -352,6 +353,9 @@ transform = Transform3D(15, 0, 0, 0, 15, 0, 0, 0, 15, 1.301034, -1.2294581, 2.06
[node name="WorldWeaponSword" parent="WeaponsContainer" instance=ExtResource("5_cwx4m")] [node name="WorldWeaponSword" parent="WeaponsContainer" instance=ExtResource("5_cwx4m")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.0268106, 2.6057472, 8.836907) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.0268106, 2.6057472, 8.836907)
[node name="WorldWeaponSword2" parent="WeaponsContainer" instance=ExtResource("6_xerh7")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.32151043, 5.2709904)
[connection signal="pressed" from="Menu/MainContainer/MainMenu/Buttons/Host" to="." method="_on_host_pressed"] [connection signal="pressed" from="Menu/MainContainer/MainMenu/Buttons/Host" to="." method="_on_host_pressed"]
[connection signal="pressed" from="Menu/MainContainer/MainMenu/Buttons/Join" to="." method="_on_join_pressed"] [connection signal="pressed" from="Menu/MainContainer/MainMenu/Buttons/Join" to="." method="_on_join_pressed"]
[connection signal="pressed" from="Menu/MainContainer/MainMenu/Option4/Quit" to="." method="_on_quit_pressed"] [connection signal="pressed" from="Menu/MainContainer/MainMenu/Option4/Quit" to="." method="_on_quit_pressed"]

@ -0,0 +1,8 @@
[gd_scene load_steps=2 format=3 uid="uid://cehc5ckhq2byd"]
[ext_resource type="PackedScene" uid="uid://c3e6e3s2q0uro" path="res://assets/Objects/Applecorer.glb" id="1_yadub"]
[node name="TestSwordMesh" type="Node3D"]
[node name="Applecorer" parent="." instance=ExtResource("1_yadub")]
transform = Transform3D(-0.3, 0, -2.6226834e-08, 0, 0.3, 0, 2.6226834e-08, 0, -0.3, 0, 0, 0)

@ -0,0 +1,17 @@
[gd_scene load_steps=4 format=3 uid="uid://8c4l6s6x67vh"]
[ext_resource type="Script" uid="uid://ccnnd0y4jqiot" path="res://level/scripts/world_weapon.gd" id="1_7688s"]
[ext_resource type="Resource" uid="uid://b2q62xc0jw4w3" path="res://level/resources/weapon_applecorer.tres" id="2_7688s"]
[sub_resource type="BoxShape3D" id="1"]
size = Vector3(0.3, 0.3, 1.2)
[node name="WorldWeaponSword" type="RigidBody3D"]
collision_layer = 4
collision_mask = 2
mass = 2.0
script = ExtResource("1_7688s")
weapon_data = ExtResource("2_7688s")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("1")

@ -48,9 +48,12 @@ func perform_attack() -> bool:
if owner_character and owner_character.is_multiplayer_authority(): if owner_character and owner_character.is_multiplayer_authority():
owner_character._attack_timer = weapon_data.attack_cooldown owner_character._attack_timer = weapon_data.attack_cooldown
# Play attack animation on owner # Play attack animation on owner (use weapon's animation)
if owner_character._body: if owner_character._body:
owner_character._body.play_attack() var anim_name = weapon_data.attack_animation if weapon_data.attack_animation else "Attack_OneHand"
owner_character._body.play_attack(anim_name)
# Sync animation to other clients
owner_character._sync_attack_animation.rpc(anim_name)
# Delay damage until animation hits (roughly 70% through the animation) # Delay damage until animation hits (roughly 70% through the animation)
# This makes the damage apply when the swing actually connects # This makes the damage apply when the swing actually connects

@ -16,7 +16,7 @@ func animate(_velocity: Vector3) -> void:
return return
# Don't override attack animation if it's playing # Don't override attack animation if it's playing
if animation_player.is_playing() and animation_player.current_animation == "Attack_OneHand": if animation_player.is_playing() and animation_player.current_animation.begins_with("Attack"):
return return
# Check if we're dashing # Check if we're dashing
@ -54,9 +54,14 @@ func _play_animation(anim_name: String):
animation_player.play(anim_name) animation_player.play(anim_name)
# Silently ignore if animation doesn't exist # Silently ignore if animation doesn't exist
func play_attack() -> void: func play_attack(anim_name: String = "Attack_OneHand") -> void:
if animation_player: if animation_player:
# Play attack animation once (don't loop) # Play attack animation once (don't loop)
animation_player.play("Attack_OneHand", -1, 1.0) if animation_player.has_animation(anim_name):
# Ensure it doesn't loop animation_player.play(anim_name, -1, 1.0)
animation_player.animation_set_next("Attack_OneHand", "") animation_player.animation_set_next(anim_name, "")
else:
# Fallback to default if animation doesn't exist
push_warning("Animation '%s' not found, using Attack_OneHand" % anim_name)
animation_player.play("Attack_OneHand", -1, 1.0)
animation_player.animation_set_next("Attack_OneHand", "")

@ -392,7 +392,7 @@ func _perform_attack():
# Fallback to default unarmed attack # Fallback to default unarmed attack
# Don't attack if already attacking # Don't attack if already attacking
if _body and _body.animation_player and _body.animation_player.current_animation == "Attack1": if _body and _body.animation_player and _body.animation_player.current_animation.begins_with("Attack"):
return return
if _attack_timer > 0: if _attack_timer > 0:
@ -402,7 +402,9 @@ func _perform_attack():
# Play attack animation once # Play attack animation once
if _body: if _body:
_body.play_attack() _body.play_attack("Attack_OneHand")
# Sync animation to other clients
_sync_attack_animation.rpc("Attack_OneHand")
# Find nearest enemy in range # Find nearest enemy in range
var space_state = get_world_3d().direct_space_state var space_state = get_world_3d().direct_space_state
@ -524,6 +526,12 @@ func _perform_dash():
# Animation is handled by the Body's animate function (Jump animation plays during dash) # Animation is handled by the Body's animate function (Jump animation plays during dash)
## Sync attack animation to all clients
@rpc("any_peer", "call_remote", "unreliable")
func _sync_attack_animation(anim_name: String):
if _body:
_body.play_attack(anim_name)
## Override hurt animation from BaseUnit ## Override hurt animation from BaseUnit
func _play_hurt_animation(): func _play_hurt_animation():
if _body and _body.animation_player: if _body and _body.animation_player:

Loading…
Cancel
Save