Attack animation
added auto fill buttons on the menu
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user