Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rifle firing, prevent it when reload animation is playing #225

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions COGITO/Wieldables/wieldable_laser_rifle.gd
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ var spawn_node : Node
var is_firing : bool = false

var firing_cooldown : float
var player_rid : RID

var inventory_item_reference : WieldableItemPD


func _ready():
wieldable_mesh.hide()
firing_cooldown = 0
player_rid = CogitoSceneManager._current_player_node.get_rid()


func _physics_process(_delta: float) -> void:
Expand All @@ -38,6 +40,8 @@ func _physics_process(_delta: float) -> void:

if is_firing:
if firing_cooldown <= 0:
if animation_player.is_playing():
return
# Gettting camera_collision pos from player interaction component:
var _camera_collision = player_interaction_component.Get_Camera_Collision()
hit_scan_collision(_camera_collision) #Do the hitscan
Expand Down Expand Up @@ -83,6 +87,7 @@ func action_secondary(is_released:bool):
func hit_scan_collision(collision_point:Vector3):
var bullet_direction = (collision_point - bullet_point.get_global_transform().origin).normalized()
var new_intersection = PhysicsRayQueryParameters3D.create(bullet_point.get_global_transform().origin, collision_point + bullet_direction * 2)
new_intersection.exclude = [player_rid]

var bullet_collision = get_world_3d().direct_space_state.intersect_ray(new_intersection)

Expand Down