started work on arrows

This commit is contained in:
derek
2025-06-26 12:18:02 -05:00
parent e1b09df8f4
commit f7d3476a56
13 changed files with 150 additions and 4 deletions

24
Scripts/ranged_attack.gd Normal file
View File

@@ -0,0 +1,24 @@
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)