started work on arrows
This commit is contained in:
24
Scripts/ranged_attack.gd
Normal file
24
Scripts/ranged_attack.gd
Normal 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)
|
||||
Reference in New Issue
Block a user