randomgeon/player/scripts/player_combat.gd
Dan Baker 1a959fbc0c Improves lightning projectile behavior
Refactors the lightning projectile to handle collisions more effectively. It now stops upon hitting an enemy or object, triggers an explosion, and spawns child projectiles from the collision point.  The lightning bolt's collision shape is dynamically updated to match the remaining distance to the target or the collision point. Also adds more test enemies to the map for testing purposes.
2025-05-06 09:30:44 +01:00

22 lines
646 B
GDScript

extends Resource
class_name PlayerCombat
var player: CharacterBody2D
var animated_sprite: AnimatedSprite2D
func process(_delta):
if Input.is_action_pressed("fire"):
var mouse_position = player.get_global_mouse_position()
var player_position = player.global_position
var direction = mouse_position - player_position
var normalized_direction = direction.normalized()
player.weapon.fire(normalized_direction, mouse_position)
# Update animation
#update_animation()
func update_animation():
Log.pr(animated_sprite.animation)
if animated_sprite.animation != "throw":
Log.pr('Throwing animation!')
animated_sprite.play("throw")