Skip to content

Commit

Permalink
Add resource decay animations, closes #67
Browse files Browse the repository at this point in the history
  • Loading branch information
Scony committed Dec 17, 2023
1 parent bea3c74 commit d59a9df
Show file tree
Hide file tree
Showing 6 changed files with 199 additions and 1 deletion.
78 changes: 78 additions & 0 deletions assets/models/primitives/icosphere.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Blender v3.0.0 OBJ File: ''
# www.blender.org
o Icosphere_Icosphere.001
v 0.000000 -1.000000 0.000000
v 0.723600 -0.447215 0.525720
v -0.276385 -0.447215 0.850640
v -0.894425 -0.447215 0.000000
v -0.276385 -0.447215 -0.850640
v 0.723600 -0.447215 -0.525720
v 0.276385 0.447215 0.850640
v -0.723600 0.447215 0.525720
v -0.723600 0.447215 -0.525720
v 0.276385 0.447215 -0.850640
v 0.894425 0.447215 0.000000
v 0.000000 1.000000 0.000000
vt 0.181819 0.000000
vt 0.272728 0.157461
vt 0.090910 0.157461
vt 0.363637 0.000000
vt 0.454546 0.157461
vt 0.909091 0.000000
vt 1.000000 0.157461
vt 0.818182 0.157461
vt 0.727273 0.000000
vt 0.636364 0.157461
vt 0.545455 0.000000
vt 0.363637 0.314921
vt 0.181819 0.314921
vt 0.909091 0.314921
vt 0.727273 0.314921
vt 0.545455 0.314921
vt 0.000000 0.314921
vt 0.272728 0.472382
vt 0.090910 0.472382
vt 0.818182 0.472382
vt 0.636364 0.472382
vt 0.454546 0.472382
vn 0.1876 -0.7947 0.5774
vn 0.6071 -0.7947 0.0000
vn -0.4911 -0.7947 0.3568
vn -0.4911 -0.7947 -0.3568
vn 0.1876 -0.7947 -0.5774
vn 0.9822 -0.1876 0.0000
vn 0.3035 -0.1876 0.9342
vn -0.7946 -0.1876 0.5774
vn -0.7946 -0.1876 -0.5774
vn 0.3035 -0.1876 -0.9342
vn 0.7946 0.1876 0.5774
vn -0.3035 0.1876 0.9342
vn -0.9822 0.1876 0.0000
vn -0.3035 0.1876 -0.9342
vn 0.7946 0.1876 -0.5774
vn 0.4911 0.7947 0.3568
vn -0.1876 0.7947 0.5774
vn -0.6071 0.7947 0.0000
vn -0.1876 0.7947 -0.5774
vn 0.4911 0.7947 -0.3568
s off
f 1/1/1 2/2/1 3/3/1
f 2/2/2 1/4/2 6/5/2
f 1/6/3 3/7/3 4/8/3
f 1/9/4 4/8/4 5/10/4
f 1/11/5 5/10/5 6/5/5
f 2/2/6 6/5/6 11/12/6
f 3/3/7 2/2/7 7/13/7
f 4/8/8 3/7/8 8/14/8
f 5/10/9 4/8/9 9/15/9
f 6/5/10 5/10/10 10/16/10
f 2/2/11 11/12/11 7/13/11
f 3/3/12 7/13/12 8/17/12
f 4/8/13 8/14/13 9/15/13
f 5/10/14 9/15/14 10/16/14
f 6/5/15 10/16/15 11/12/15
f 7/13/16 11/12/16 12/18/16
f 8/17/17 7/13/17 12/19/17
f 9/15/18 8/14/18 12/20/18
f 10/16/19 9/15/19 12/21/19
f 11/12/20 10/16/20 12/22/20
22 changes: 22 additions & 0 deletions assets/models/primitives/icosphere.obj.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[remap]

importer="wavefront_obj"
importer_version=1
type="Mesh"
uid="uid://b4iu37hx5nsmp"
path="res://.godot/imported/icosphere.obj-e49a82048b23f2140e3aa30c9b8b65ca.mesh"

[deps]

files=["res://.godot/imported/icosphere.obj-e49a82048b23f2140e3aa30c9b8b65ca.mesh"]

source_file="res://assets/models/primitives/icosphere.obj"
dest_files=["res://.godot/imported/icosphere.obj-e49a82048b23f2140e3aa30c9b8b65ca.mesh", "res://.godot/imported/icosphere.obj-e49a82048b23f2140e3aa30c9b8b65ca.mesh"]

[params]

generate_tangents=true
scale_mesh=Vector3(1, 1, 1)
offset_mesh=Vector3(0, 0, 0)
optimize_mesh=true
force_disable_mesh_compression=false
12 changes: 12 additions & 0 deletions source/match/units/non-player/ResourceUnit.gd
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
extends Area3D

const ResourceDecayAnimation = preload("res://source/match/utils/ResourceDecayAnimation.tscn")

var radius = null:
set = _ignore,
get = _get_radius


func _enter_tree():
tree_exiting.connect(_animate_decay)


func _ignore(_value):
pass


func _get_radius():
return find_child("MovementObstacle").radius


func _animate_decay():
var decay_animation = ResourceDecayAnimation.instantiate()
decay_animation.global_transform = global_transform
get_parent().add_child.call_deferred(decay_animation)
9 changes: 9 additions & 0 deletions source/match/utils/ResourceDecayAnimation.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
extends Node3D

@onready var _particles = find_child("GPUParticles3D")


func _ready():
await get_tree().physics_frame # wait one frame for transform to propagate
_particles.finished.connect(queue_free)
_particles.emitting = true
47 changes: 47 additions & 0 deletions source/match/utils/ResourceDecayAnimation.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[gd_scene load_steps=9 format=3 uid="uid://th6p6c16rur5"]

[ext_resource type="ArrayMesh" uid="uid://b4iu37hx5nsmp" path="res://assets/models/primitives/icosphere.obj" id="1_2m585"]
[ext_resource type="Script" path="res://source/match/utils/ResourceDecayAnimation.gd" id="1_wnl5r"]

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_eoeij"]
transparency = 1
vertex_color_use_as_albedo = true

[sub_resource type="Gradient" id="Gradient_n80mp"]
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0)

[sub_resource type="GradientTexture1D" id="GradientTexture1D_v2005"]
gradient = SubResource("Gradient_n80mp")

[sub_resource type="Curve" id="Curve_eymjl"]
max_value = 3.0
_data = [Vector2(0, 0.396055), 0.0, 0.0, 0, 0, Vector2(0.0147602, 3), 0.0, 0.0, 0, 0]
point_count = 2

[sub_resource type="CurveTexture" id="CurveTexture_om0lt"]
curve = SubResource("Curve_eymjl")

[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_4ju5i"]
emission_shape_offset = Vector3(0, 0.1, 0)
emission_shape = 1
emission_sphere_radius = 0.5
gravity = Vector3(0, 0.1, 0)
linear_accel_min = 0.01
linear_accel_max = 0.05
scale_min = 0.05
scale_max = 0.15
scale_over_velocity_curve = SubResource("CurveTexture_om0lt")
color = Color(0.960784, 0.745098, 0.654902, 1)
color_ramp = SubResource("GradientTexture1D_v2005")

[node name="ResourceDecayAnimation" type="Node3D"]
script = ExtResource("1_wnl5r")

[node name="GPUParticles3D" type="GPUParticles3D" parent="."]
material_override = SubResource("StandardMaterial3D_eoeij")
emitting = false
one_shot = true
speed_scale = 2.0
explosiveness = 0.79
process_material = SubResource("ParticleProcessMaterial_4ju5i")
draw_pass_1 = ExtResource("1_2m585")
32 changes: 31 additions & 1 deletion tests/manual/TestAllUnits.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=23 format=3 uid="uid://b65yuqx0iw62f"]
[gd_scene load_steps=27 format=3 uid="uid://b65yuqx0iw62f"]

[ext_resource type="PackedScene" uid="uid://camns8fqod8d4" path="res://source/match/Match.tscn" id="1_oiu0k"]
[ext_resource type="Script" path="res://tests/manual/Match.gd" id="2_ghr3h"]
Expand All @@ -10,9 +10,12 @@
[ext_resource type="PackedScene" uid="uid://h5lqor1xl2sf" path="res://source/match/units/VehicleFactory.tscn" id="4_m1xri"]
[ext_resource type="Shader" path="res://source/shaders/3d/simple_fog_of_war.gdshader" id="5_f2ny6"]
[ext_resource type="PackedScene" uid="uid://b8pckq1xn44ss" path="res://source/match/units/AntiGroundTurret.tscn" id="5_g67iu"]
[ext_resource type="Material" uid="uid://co8vfcoqqs5i8" path="res://source/match/resources/materials/terrain.material.tres" id="5_q15cp"]
[ext_resource type="PackedScene" uid="uid://cbe63rdjw7y4p" path="res://source/match/maps/PlainAndSimple.tscn" id="5_t3ibh"]
[ext_resource type="PackedScene" uid="uid://dh8dedilkhuoy" path="res://source/match/players/human/Human.tscn" id="5_tlbff"]
[ext_resource type="PackedScene" uid="uid://bf3jjdafqvh0w" path="res://source/match/units/non-player/ResourceA.tscn" id="6_414qe"]
[ext_resource type="PackedScene" uid="uid://cfa8cpnpk5pcb" path="res://source/match/units/AntiAirTurret.tscn" id="6_lglnp"]
[ext_resource type="PackedScene" uid="uid://bufgjfa3ne3uk" path="res://source/match/units/non-player/ResourceB.tscn" id="7_g0wbf"]
[ext_resource type="PackedScene" uid="uid://i58ffvwxbbwm" path="res://source/match/units/Tank.tscn" id="9_csgr3"]
[ext_resource type="PackedScene" uid="uid://bf0r3fovbvf1m" path="res://source/match/units/Worker.tscn" id="10_c3eov"]
[ext_resource type="Shader" path="res://source/shaders/2d/white_transparent.gdshader" id="16_mqpbu"]
Expand All @@ -23,6 +26,12 @@ players = Array[Resource]([])
visibility = 1
visible_player = 0

[sub_resource type="PlaneMesh" id="PlaneMesh_ynnr0"]
resource_local_to_scene = true
material = ExtResource("5_q15cp")
size = Vector2(50, 50)
center_offset = Vector3(25, 0, 25)

[sub_resource type="ViewportTexture" id="ViewportTexture_v46ss"]
viewport_path = NodePath("FogOfWar/CombinedViewport")

Expand Down Expand Up @@ -53,6 +62,25 @@ settings = SubResource("Resource_rpdec")

[node name="Map" parent="." index="0" instance=ExtResource("5_t3ibh")]

[node name="Terrain" parent="Map/Geometry" index="1"]
mesh = SubResource("PlaneMesh_ynnr0")

[node name="ResourceA13" parent="Map/Resources" index="2" instance=ExtResource("6_414qe")]
transform = Transform3D(0.157813, 0, -0.987469, 0, 1, 0, 0.987469, 0, 0.157813, 8.48506, -7.15256e-06, 13.997)
resource_a = 2

[node name="ResourceA14" parent="Map/Resources" index="3" instance=ExtResource("6_414qe")]
transform = Transform3D(0.157813, 0, -0.987469, 0, 1, 0, 0.987469, 0, 0.157813, 10.6949, -7.15256e-06, 16.48)
resource_a = 2

[node name="ResourceA15" parent="Map/Resources" index="4" instance=ExtResource("6_414qe")]
transform = Transform3D(0.157813, 0, -0.987469, 0, 1, 0, 0.987469, 0, 0.157813, 11.6939, -7.15256e-06, 17.7958)
resource_a = 2

[node name="ResourceB5" parent="Map/Resources" index="10" instance=ExtResource("7_g0wbf")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 12.9437, -7.62939e-06, 16.1825)
resource_b = 2

[node name="Human" parent="Players" index="0" instance=ExtResource("5_tlbff")]

[node name="CommandCenter" parent="Players/Human" index="1" instance=ExtResource("2_rm00b")]
Expand Down Expand Up @@ -90,3 +118,5 @@ material = SubResource("ShaderMaterial_i0ai6")

[node name="MinimapTextureRect" parent="HUD/MarginContainer/Minimap/MarginContainer" index="1"]
texture = SubResource("ViewportTexture_ltqxy")

[editable path="Map"]

0 comments on commit d59a9df

Please sign in to comment.