From fbad53069ea56c14366c2b1a8bac2aa0a7859c90 Mon Sep 17 00:00:00 2001 From: Salonso928 Date: Thu, 27 Aug 2026 19:27:15 -0500 Subject: [PATCH 1/3] Add a visual clue to indicate the projectiles are about to dissapear --- .../props/projectile/components/projectile.gd | 21 +++++++++- .../NO_EDIT_projectile.tscn | 41 +++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/scenes/game_elements/props/projectile/components/projectile.gd b/scenes/game_elements/props/projectile/components/projectile.gd index 99f35d918f..3059e3e363 100644 --- a/scenes/game_elements/props/projectile/components/projectile.gd +++ b/scenes/game_elements/props/projectile/components/projectile.gd @@ -68,7 +68,11 @@ var _trail_particles: GPUParticles2D @onready var visible_things: Node2D = %VisibleThings @onready var animated_sprite_2d: AnimatedSprite2D = %AnimatedSprite2D @onready var trail_fx_marker: Marker2D = %TrailFXMarker +@onready var animation_player: AnimationPlayer = %AnimationPlayer +var time_passed:float = 0.0 +var time_to_dissapear:float = 0.0 +var is_dissapearing:bool = false ## How long the projectile lives in the scene. ## [br][br] ## This timer is restarted each time the projectile collides with anything. @@ -111,6 +115,7 @@ func _ready() -> void: duration_timer.start() var impulse: Vector2 = direction * speed apply_impulse(impulse) + time_to_dissapear = duration*0.8 func _process(_delta: float) -> void: @@ -121,6 +126,11 @@ func _process(_delta: float) -> void: ) var force: Vector2 = direction_to_target * speed constant_force = force + + time_passed+=_delta + if time_passed>= time_to_dissapear && not is_dissapearing: + is_dissapearing=true + animation_player.play("dissapear") ## Add a small effect scene to the current scene in the current position. @@ -136,7 +146,12 @@ func add_small_fx() -> void: func _on_body_entered(body: Node2D) -> void: add_small_fx() - duration_timer.start() + + # Logic for the dissapear animation + # When the proyectile is dissapearing, the duration_timer will not reset + if not is_dissapearing: + duration_timer.start() + time_passed=0.0 # Logic for Fragile Barrel # We must check for the specific subclass first because it inherits from FillingBarrel @@ -157,7 +172,9 @@ func _on_body_entered(body: Node2D) -> void: ## enters the repel area. func got_repelled(repel_direction: Vector2) -> void: add_small_fx() - duration_timer.start() + if not is_dissapearing: + duration_timer.start() + time_passed=0.0 var hit_vector: Vector2 = repel_direction * hit_speed hit_sound.play() animated_sprite_2d.speed_scale = 2 diff --git a/scenes/quests/template_quests/NO_EDIT/2_NO_EDIT_combat/NO_EDIT_combat_components/NO_EDIT_projectile.tscn b/scenes/quests/template_quests/NO_EDIT/2_NO_EDIT_combat/NO_EDIT_combat_components/NO_EDIT_projectile.tscn index 9ab6633abb..1b2db97401 100644 --- a/scenes/quests/template_quests/NO_EDIT/2_NO_EDIT_combat/NO_EDIT_combat_components/NO_EDIT_projectile.tscn +++ b/scenes/quests/template_quests/NO_EDIT/2_NO_EDIT_combat/NO_EDIT_combat_components/NO_EDIT_projectile.tscn @@ -10,6 +10,43 @@ bounce = 1.0 [sub_resource type="RectangleShape2D" id="RectangleShape2D_o6xl0"] size = Vector2(44, 44) +[sub_resource type="Animation" id="Animation_w1dj1"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("VisibleThings/AnimatedSprite2D:modulate") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Color(1, 1, 1, 1)] +} + +[sub_resource type="Animation" id="Animation_lrx48"] +resource_name = "dissapear" +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("VisibleThings/AnimatedSprite2D:modulate") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.25, 0.5, 0.75, 1), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1), +"update": 0, +"values": [Color(1, 1, 1, 0.19607843), Color(1, 1, 1, 0.78431374), Color(1, 1, 1, 0.19607843), Color(1, 1, 1, 0.78431374), Color(1, 1, 1, 0.19607843)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_us7pj"] +_data = { +&"RESET": SubResource("Animation_w1dj1"), +&"dissapear": SubResource("Animation_lrx48") +} + [node name="NoEditProjectile" type="RigidBody2D" unique_id=1611529190 groups=["projectiles"]] collision_layer = 256 collision_mask = 80 @@ -45,5 +82,9 @@ unique_name_in_owner = true unique_name_in_owner = true bus = &"SFX" +[node name="AnimationPlayer" type="AnimationPlayer" parent="." unique_id=902059992] +unique_name_in_owner = true +libraries/ = SubResource("AnimationLibrary_us7pj") + [connection signal="body_entered" from="." to="." method="_on_body_entered"] [connection signal="timeout" from="DurationTimer" to="." method="_on_duration_timer_timeout"] From 8c35cfba93fc3dd9cfc1b640577e7d742fcc6336 Mon Sep 17 00:00:00 2001 From: Salonso928 Date: Fri, 28 Aug 2026 11:59:07 -0500 Subject: [PATCH 2/3] Remove AnimationPlayer node from the projectile scene, now the blink effect is only controlled by the projectile.gd script --- .../props/projectile/components/projectile.gd | 50 ++++++++++++++----- .../NO_EDIT_projectile.tscn | 41 --------------- 2 files changed, 38 insertions(+), 53 deletions(-) diff --git a/scenes/game_elements/props/projectile/components/projectile.gd b/scenes/game_elements/props/projectile/components/projectile.gd index 3059e3e363..6b4764a176 100644 --- a/scenes/game_elements/props/projectile/components/projectile.gd +++ b/scenes/game_elements/props/projectile/components/projectile.gd @@ -68,11 +68,14 @@ var _trail_particles: GPUParticles2D @onready var visible_things: Node2D = %VisibleThings @onready var animated_sprite_2d: AnimatedSprite2D = %AnimatedSprite2D @onready var trail_fx_marker: Marker2D = %TrailFXMarker -@onready var animation_player: AnimationPlayer = %AnimationPlayer -var time_passed:float = 0.0 -var time_to_dissapear:float = 0.0 -var is_dissapearing:bool = false +#Attributes that control the blinking effect +var time_passed: float = 0.0 +var time_to_dissapear: float = 0.0 +var is_dissapearing: bool = false +var blink_effect: bool = true +var blink_timer: Timer + ## How long the projectile lives in the scene. ## [br][br] ## This timer is restarted each time the projectile collides with anything. @@ -115,8 +118,19 @@ func _ready() -> void: duration_timer.start() var impulse: Vector2 = direction * speed apply_impulse(impulse) - time_to_dissapear = duration*0.8 - + + ##the effect will start when the projectile has spent 70% of its lifetime + time_to_dissapear = duration * 0.7 + + blink_timer = Timer.new() + #each 0.25 seconds the blink effect will show + blink_timer.wait_time = 0.25 + blink_timer.one_shot = false + blink_timer.timeout.connect(_on_blink_timer_timeout) + + add_child(blink_timer) + + func _process(_delta: float) -> void: visible_things.rotation = linear_velocity.angle() @@ -127,10 +141,11 @@ func _process(_delta: float) -> void: var force: Vector2 = direction_to_target * speed constant_force = force - time_passed+=_delta - if time_passed>= time_to_dissapear && not is_dissapearing: - is_dissapearing=true - animation_player.play("dissapear") + time_passed += _delta + if time_passed >= time_to_dissapear && not is_dissapearing: + is_dissapearing = true + blink_timer.start() + ## Add a small effect scene to the current scene in the current position. @@ -151,7 +166,7 @@ func _on_body_entered(body: Node2D) -> void: # When the proyectile is dissapearing, the duration_timer will not reset if not is_dissapearing: duration_timer.start() - time_passed=0.0 + time_passed = 0.0 # Logic for Fragile Barrel # We must check for the specific subclass first because it inherits from FillingBarrel @@ -172,9 +187,12 @@ func _on_body_entered(body: Node2D) -> void: ## enters the repel area. func got_repelled(repel_direction: Vector2) -> void: add_small_fx() + + # When the proyectile is dissapearing, the duration_timer will not reset if not is_dissapearing: duration_timer.start() - time_passed=0.0 + time_passed = 0.0 + var hit_vector: Vector2 = repel_direction * hit_speed hit_sound.play() animated_sprite_2d.speed_scale = 2 @@ -203,3 +221,11 @@ func _on_duration_timer_timeout() -> void: func remove() -> void: await get_tree().create_timer(randf_range(0., 3.)).timeout explode() + +func _on_blink_timer_timeout() -> void: + if blink_effect: + animated_sprite_2d.modulate.a = 0.2 + blink_effect = false + else: + animated_sprite_2d.modulate.a = 0.8 + blink_effect = true diff --git a/scenes/quests/template_quests/NO_EDIT/2_NO_EDIT_combat/NO_EDIT_combat_components/NO_EDIT_projectile.tscn b/scenes/quests/template_quests/NO_EDIT/2_NO_EDIT_combat/NO_EDIT_combat_components/NO_EDIT_projectile.tscn index 1b2db97401..9ab6633abb 100644 --- a/scenes/quests/template_quests/NO_EDIT/2_NO_EDIT_combat/NO_EDIT_combat_components/NO_EDIT_projectile.tscn +++ b/scenes/quests/template_quests/NO_EDIT/2_NO_EDIT_combat/NO_EDIT_combat_components/NO_EDIT_projectile.tscn @@ -10,43 +10,6 @@ bounce = 1.0 [sub_resource type="RectangleShape2D" id="RectangleShape2D_o6xl0"] size = Vector2(44, 44) -[sub_resource type="Animation" id="Animation_w1dj1"] -length = 0.001 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("VisibleThings/AnimatedSprite2D:modulate") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [Color(1, 1, 1, 1)] -} - -[sub_resource type="Animation" id="Animation_lrx48"] -resource_name = "dissapear" -loop_mode = 1 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("VisibleThings/AnimatedSprite2D:modulate") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 0.25, 0.5, 0.75, 1), -"transitions": PackedFloat32Array(1, 1, 1, 1, 1), -"update": 0, -"values": [Color(1, 1, 1, 0.19607843), Color(1, 1, 1, 0.78431374), Color(1, 1, 1, 0.19607843), Color(1, 1, 1, 0.78431374), Color(1, 1, 1, 0.19607843)] -} - -[sub_resource type="AnimationLibrary" id="AnimationLibrary_us7pj"] -_data = { -&"RESET": SubResource("Animation_w1dj1"), -&"dissapear": SubResource("Animation_lrx48") -} - [node name="NoEditProjectile" type="RigidBody2D" unique_id=1611529190 groups=["projectiles"]] collision_layer = 256 collision_mask = 80 @@ -82,9 +45,5 @@ unique_name_in_owner = true unique_name_in_owner = true bus = &"SFX" -[node name="AnimationPlayer" type="AnimationPlayer" parent="." unique_id=902059992] -unique_name_in_owner = true -libraries/ = SubResource("AnimationLibrary_us7pj") - [connection signal="body_entered" from="." to="." method="_on_body_entered"] [connection signal="timeout" from="DurationTimer" to="." method="_on_duration_timer_timeout"] From be40bc93326dfc81685792373d8f0bcb1f8be180 Mon Sep 17 00:00:00 2001 From: Salonso928 Date: Sat, 29 Aug 2026 20:08:53 -0500 Subject: [PATCH 3/3] Fix linting and formatting issues --- .../props/projectile/components/projectile.gd | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scenes/game_elements/props/projectile/components/projectile.gd b/scenes/game_elements/props/projectile/components/projectile.gd index 6b4764a176..5111d384d0 100644 --- a/scenes/game_elements/props/projectile/components/projectile.gd +++ b/scenes/game_elements/props/projectile/components/projectile.gd @@ -65,10 +65,6 @@ extends RigidBody2D var _trail_particles: GPUParticles2D -@onready var visible_things: Node2D = %VisibleThings -@onready var animated_sprite_2d: AnimatedSprite2D = %AnimatedSprite2D -@onready var trail_fx_marker: Marker2D = %TrailFXMarker - #Attributes that control the blinking effect var time_passed: float = 0.0 var time_to_dissapear: float = 0.0 @@ -76,6 +72,10 @@ var is_dissapearing: bool = false var blink_effect: bool = true var blink_timer: Timer +@onready var visible_things: Node2D = %VisibleThings +@onready var animated_sprite_2d: AnimatedSprite2D = %AnimatedSprite2D +@onready var trail_fx_marker: Marker2D = %TrailFXMarker + ## How long the projectile lives in the scene. ## [br][br] ## This timer is restarted each time the projectile collides with anything. @@ -228,4 +228,4 @@ func _on_blink_timer_timeout() -> void: blink_effect = false else: animated_sprite_2d.modulate.a = 0.8 - blink_effect = true + blink_effect = true