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

1
Scripts/arrow.gd Normal file
View File

@@ -0,0 +1 @@
extends Projectile

1
Scripts/arrow.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://b0crflswpal5l

View File

@@ -16,7 +16,6 @@ func _process(delta: float) -> void:
func camera_fov():
var distance_to_target = global_position.distance_to(target.global_position)
attributes.dof_blur_far_distance = distance_to_target + 15.0
attributes.dof_blur_near_distance = distance_to_target - 3
func camera_height_change(delta):

View File

@@ -8,7 +8,7 @@ extends Node3D
func _process(delta: float) -> void:
follow_mouse()
swap_models()
look_at(player.global_position, Vector3.UP)
point_from_player()
func follow_mouse():
var mouse_pos = MousePos.get_mouse_world_position(00001000)
@@ -22,3 +22,7 @@ func swap_models():
else:
sword_cursor.visible = true
bow_cursor.visible = false
func point_from_player():
var player_pos_xz_only = Vector3(player.global_position.x,global_position.y,player.global_position.z)
look_at(player_pos_xz_only, Vector3.UP)

View File

@@ -8,3 +8,6 @@ func Physics_Update(delta):
apply_gravity(delta)
respawn_on_fall(delta)
attack()
if Input.is_action_just_pressed("ranged_attack"):
Transitioned.emit(self,"ranged attack")

5
Scripts/projectile.gd Normal file
View File

@@ -0,0 +1,5 @@
extends RigidBody3D
class_name Projectile
var damage
var speed

View File

@@ -0,0 +1 @@
uid://de4r7j0yuar0s

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)

View File

@@ -0,0 +1 @@
uid://255h63wdkwpv