-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
using animation for transform properties without additional sprites using Particle system for animating enemy death with variations
- Loading branch information
1 parent
674ad09
commit 1b3f878
Showing
6 changed files
with
300 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
extends Node2D | ||
|
||
@export var health_component: Node | ||
@export var sprite: Sprite2D | ||
|
||
func _ready(): | ||
$GPUParticles2D.texture = sprite.texture | ||
health_component.died.connect(on_died) | ||
|
||
|
||
func on_died(): | ||
if owner == null or not owner is Node2D: | ||
return | ||
|
||
var spawn_position = owner.global_position | ||
|
||
var entities = get_tree().get_first_node_in_group("entities_layer") | ||
get_parent().remove_child(self) | ||
entities.add_child(self) | ||
global_position = spawn_position | ||
$AnimationPlayer.play("default") |
90 changes: 90 additions & 0 deletions
90
2d-survivors-course/scenes/components/death_component.tscn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
[gd_scene load_steps=9 format=3 uid="uid://ccr2pyjml5e3f"] | ||
|
||
[ext_resource type="Texture2D" uid="uid://c4wr81m8ifp8g" path="res://scenes/game_object/basic_enemy/basic_enemy.png" id="1_uqrhc"] | ||
[ext_resource type="Script" path="res://scenes/components/death_component.gd" id="1_ytloj"] | ||
|
||
[sub_resource type="Animation" id="Animation_gqtrg"] | ||
length = 0.001 | ||
tracks/0/type = "value" | ||
tracks/0/imported = false | ||
tracks/0/enabled = true | ||
tracks/0/path = NodePath("GPUParticles2D:emitting") | ||
tracks/0/interp = 1 | ||
tracks/0/loop_wrap = true | ||
tracks/0/keys = { | ||
"times": PackedFloat32Array(0), | ||
"transitions": PackedFloat32Array(1), | ||
"update": 1, | ||
"values": [false] | ||
} | ||
|
||
[sub_resource type="Animation" id="Animation_6ydj7"] | ||
resource_name = "default" | ||
tracks/0/type = "value" | ||
tracks/0/imported = false | ||
tracks/0/enabled = true | ||
tracks/0/path = NodePath("GPUParticles2D:emitting") | ||
tracks/0/interp = 1 | ||
tracks/0/loop_wrap = true | ||
tracks/0/keys = { | ||
"times": PackedFloat32Array(0), | ||
"transitions": PackedFloat32Array(1), | ||
"update": 1, | ||
"values": [true] | ||
} | ||
tracks/1/type = "method" | ||
tracks/1/imported = false | ||
tracks/1/enabled = true | ||
tracks/1/path = NodePath(".") | ||
tracks/1/interp = 1 | ||
tracks/1/loop_wrap = true | ||
tracks/1/keys = { | ||
"times": PackedFloat32Array(1), | ||
"transitions": PackedFloat32Array(1), | ||
"values": [{ | ||
"args": [], | ||
"method": &"queue_free" | ||
}] | ||
} | ||
|
||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_hf1dk"] | ||
_data = { | ||
"RESET": SubResource("Animation_gqtrg"), | ||
"default": SubResource("Animation_6ydj7") | ||
} | ||
|
||
[sub_resource type="Curve" id="Curve_t1e56"] | ||
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(0.6, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] | ||
point_count = 3 | ||
|
||
[sub_resource type="CurveTexture" id="CurveTexture_sj25v"] | ||
curve = SubResource("Curve_t1e56") | ||
|
||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_fki2r"] | ||
particle_flag_disable_z = true | ||
direction = Vector3(0, -1, 0) | ||
spread = 30.0 | ||
initial_velocity_min = 175.0 | ||
initial_velocity_max = 250.0 | ||
angular_velocity_min = -1440.0 | ||
angular_velocity_max = 1440.0 | ||
gravity = Vector3(0, 800, 0) | ||
scale_curve = SubResource("CurveTexture_sj25v") | ||
|
||
[node name="DeathComponent" type="Node2D"] | ||
script = ExtResource("1_ytloj") | ||
|
||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."] | ||
libraries = { | ||
"": SubResource("AnimationLibrary_hf1dk") | ||
} | ||
|
||
[node name="GPUParticles2D" type="GPUParticles2D" parent="."] | ||
emitting = false | ||
amount = 1 | ||
process_material = SubResource("ParticleProcessMaterial_fki2r") | ||
texture = ExtResource("1_uqrhc") | ||
lifetime = 0.5 | ||
one_shot = true | ||
fixed_fps = 0 | ||
interpolate = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters