Files
DailyDungeon/Scripts/ranged_attack.gd
2025-06-26 12:18:02 -05:00

25 lines
728 B
GDScript

extends PlayerState
class_name PlayerRangedAttack
@export var fired_object : PackedScene
@export var object_speed : float = 20.0
func Enter():
character.velocity = Vector3.ZERO
func Physics_Update(delta):
body_look_at_mouse()
if Input.is_action_just_released("ranged_attack"):
fire_projectile()
Transitioned.emit(self,"on floor")
func fire_projectile():
var arrow_spawn = fired_object.instantiate()
arrow_spawn.speed = object_speed
get_tree().current_scene.add_child(arrow_spawn)
arrow_spawn.transform.basis = character.body.global_transform.basis
arrow_spawn.global_position = character.body.global_position
arrow_spawn.linear_velocity += character.body.global_transform.basis * Vector3(0,0,-object_speed)