Repository navigation
Add a visual clue to indicate the projectiles are about to dissapear #2801
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
Changes from all commits
fbad530
8c35cfb
be40bc9
5e2b469
85d8b2d
944d881
d754538
1c8426f
c768ee5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -63,6 +63,18 @@ extends RigidBody2D | |||||||||
| ## root node. When the projectile gets hit, the [member GPUParticles2D.amount_ratio] is set to 1. | ||||||||||
| @export var trail_fx_scene: PackedScene | ||||||||||
|
|
||||||||||
| @export var blink_animation_player: AnimationPlayer | ||||||||||
|
|
||||||||||
| @export_group("Dissapear Clue") | ||||||||||
|
|
||||||||||
| ## The time in seconds to show the disappear animation. | ||||||||||
| @export_range(0.0, 10.0, 0.5) var blink_duration: float = 3.0 | ||||||||||
|
Comment on lines
+70
to
+71
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "blink duration" reads to me as the duration of one blink. Sorry if I caused this trouble in previous reviews, but this should be named |
||||||||||
|
|
||||||||||
| ## The number of times the projectile blinks before disappearing. | ||||||||||
| @export_range(1, 10, 1) var blink_times: int = 3 | ||||||||||
|
|
||||||||||
| var blink_effect_time: float | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This variable is not needed, it can be calculated when needeed with duration, dissapear_duration and blink_times. |
||||||||||
| var blink_timer: Timer | ||||||||||
| var _trail_particles: GPUParticles2D | ||||||||||
|
|
||||||||||
| @onready var visible_things: Node2D = %VisibleThings | ||||||||||
|
|
@@ -71,7 +83,7 @@ var _trail_particles: GPUParticles2D | |||||||||
|
|
||||||||||
| ## How long the projectile lives in the scene. | ||||||||||
| ## [br][br] | ||||||||||
| ## This timer is restarted each time the projectile collides with anything. | ||||||||||
| ## This timer is restarted each time the projectile collies with anything. | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| ## So the life of the projectile is extended in each collision. | ||||||||||
| @onready var duration_timer: Timer = %DurationTimer | ||||||||||
|
|
||||||||||
|
|
@@ -112,6 +124,19 @@ func _ready() -> void: | |||||||||
| var impulse: Vector2 = direction * speed | ||||||||||
| apply_impulse(impulse) | ||||||||||
|
|
||||||||||
| if blink_animation_player: | ||||||||||
| #If the blink duration is greater than the duration | ||||||||||
| #The minimun time the animation will spend is 3 seconds. | ||||||||||
| var time_to_dissapear: float = max(3.0, duration - blink_duration) | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where does this 3 seconds come from? I think that if the dissapear duration is greater than the duration, it should start blinking immediately. You had this right before. |
||||||||||
| blink_timer = Timer.new() | ||||||||||
| blink_timer.wait_time = time_to_dissapear | ||||||||||
| blink_timer.one_shot = true | ||||||||||
| blink_timer.timeout.connect(_on_blink_timer_timeout) | ||||||||||
| add_child(blink_timer) | ||||||||||
| blink_timer.start() | ||||||||||
|
|
||||||||||
| blink_effect_time = (duration - time_to_dissapear) / blink_times | ||||||||||
|
|
||||||||||
|
|
||||||||||
| func _process(_delta: float) -> void: | ||||||||||
| visible_things.rotation = linear_velocity.angle() | ||||||||||
|
|
@@ -135,8 +160,7 @@ func add_small_fx() -> void: | |||||||||
|
|
||||||||||
|
|
||||||||||
| func _on_body_entered(body: Node2D) -> void: | ||||||||||
| add_small_fx() | ||||||||||
| duration_timer.start() | ||||||||||
| _on_projectile_hit() | ||||||||||
|
|
||||||||||
| # Logic for Fragile Barrel | ||||||||||
| # We must check for the specific subclass first because it inherits from FillingBarrel | ||||||||||
|
|
@@ -156,8 +180,7 @@ func _on_body_entered(body: Node2D) -> void: | |||||||||
| ## Called from the Repel component when this body | ||||||||||
| ## enters the repel area. | ||||||||||
| func got_repelled(repel_direction: Vector2) -> void: | ||||||||||
| add_small_fx() | ||||||||||
| duration_timer.start() | ||||||||||
| _on_projectile_hit() | ||||||||||
| var hit_vector: Vector2 = repel_direction * hit_speed | ||||||||||
| hit_sound.play() | ||||||||||
| animated_sprite_2d.speed_scale = 2 | ||||||||||
|
|
@@ -186,3 +209,23 @@ 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: | ||||||||||
| var animation_duration: float = blink_animation_player.get_animation("dissapear").length | ||||||||||
| blink_animation_player.play("dissapear", -1, animation_duration / blink_effect_time) | ||||||||||
|
|
||||||||||
|
|
||||||||||
| func _on_projectile_hit() -> void: | ||||||||||
| add_small_fx() | ||||||||||
|
|
||||||||||
| # Reset timers and blink animation: | ||||||||||
| duration_timer.start() | ||||||||||
|
|
||||||||||
| if blink_animation_player: | ||||||||||
| #If the projectile collides with another object or is repelled the animation and timer will reset | ||||||||||
| if blink_timer.is_stopped(): | ||||||||||
| blink_animation_player.play("RESET") | ||||||||||
| blink_timer.start() | ||||||||||
| else: | ||||||||||
| blink_timer.start() | ||||||||||
|
Comment on lines
+229
to
+231
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If and else have the same content, is better to do:
Suggested change
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,45 @@ bounce = 1.0 | |
| [sub_resource type="RectangleShape2D" id="RectangleShape2D_o6xl0"] | ||
| size = Vector2(44, 44) | ||
|
|
||
| [node name="InkBlobProjectile" type="RigidBody2D" unique_id=1611529190 groups=["projectiles"]] | ||
| [sub_resource type="Animation" id="Animation_inmjt"] | ||
| length = 0.001 | ||
| tracks/0/type = "value" | ||
| tracks/0/imported = false | ||
| tracks/0/enabled = true | ||
| tracks/0/path = NodePath(".:modulate:a") | ||
| tracks/0/interp = 1 | ||
| tracks/0/loop_wrap = true | ||
| tracks/0/keys = { | ||
| "times": PackedFloat32Array(0), | ||
| "transitions": PackedFloat32Array(1), | ||
| "update": 1, | ||
| "values": [1.0] | ||
| } | ||
|
|
||
| [sub_resource type="Animation" id="Animation_41322"] | ||
| resource_name = "disappear" | ||
| length = 0.5 | ||
| loop_mode = 1 | ||
| tracks/0/type = "value" | ||
| tracks/0/imported = false | ||
| tracks/0/enabled = true | ||
| tracks/0/path = NodePath(".:modulate:a") | ||
| tracks/0/interp = 1 | ||
| tracks/0/loop_wrap = true | ||
| tracks/0/keys = { | ||
| "times": PackedFloat32Array(0, 0.25, 0.5), | ||
| "transitions": PackedFloat32Array(1, 1, 1), | ||
| "update": 0, | ||
| "values": [0.8, 0.25, 0.8] | ||
| } | ||
|
|
||
| [sub_resource type="AnimationLibrary" id="AnimationLibrary_3lot6"] | ||
| _data = { | ||
| &"RESET": SubResource("Animation_inmjt"), | ||
| &"dissapear": SubResource("Animation_41322") | ||
| } | ||
|
|
||
| [node name="InkBlobProjectile" type="RigidBody2D" unique_id=1611529190 node_paths=PackedStringArray("blink_animation_player") groups=["projectiles"]] | ||
| collision_layer = 256 | ||
| collision_mask = 80 | ||
| mass = 0.3 | ||
|
|
@@ -28,6 +66,8 @@ script = ExtResource("1_gkhfg") | |
| small_fx_scene = ExtResource("3_inmjt") | ||
| big_fx_scene = ExtResource("4_41322") | ||
| trail_fx_scene = ExtResource("5_3lot6") | ||
| blink_animation_player = NodePath("AnimationPlayer") | ||
| blink_times = 5 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As requested before, let's reset this to the default. |
||
|
|
||
| [node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1499726276] | ||
| shape = SubResource("RectangleShape2D_o6xl0") | ||
|
|
@@ -53,5 +93,8 @@ unique_name_in_owner = true | |
| stream = ExtResource("3_faii4") | ||
| bus = &"SFX" | ||
|
|
||
| [node name="AnimationPlayer" type="AnimationPlayer" parent="." unique_id=304068808] | ||
| libraries/ = SubResource("AnimationLibrary_3lot6") | ||
|
|
||
| [connection signal="body_entered" from="." to="." method="_on_body_entered"] | ||
| [connection signal="timeout" from="DurationTimer" to="." method="_on_duration_timer_timeout"] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand that you changed this level by accident, while testing. Please revert it.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is still the case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a documentation comment explaining that this AnimationPlayer needs to have an animation called "dissapear". By the way, I think that the animation can be called "blink". And even better, we can add a warning in the editor when the AnimationPlayer that was set in the Inspector doesn't have one. But I can open a separate ticket for it.
Also please move the
@export_group("Dissapear Clue")line above this one, so this export belongs to that group. Would you agree with that?