PARTICLES

This commit is contained in:
Victor Turgeon 2022-10-11 21:52:01 -04:00
parent d31b299251
commit 17cd9a332f
4 changed files with 64 additions and 52 deletions

View File

@ -24,6 +24,7 @@ height = 3.0
extents = Vector3( 0.983522, 2, 1.55035 )
[sub_resource type="SpatialMaterial" id=4]
flags_no_depth_test = true
albedo_texture = ExtResource( 3 )
uv1_triplanar = true

View File

@ -11,14 +11,13 @@ var gravity_vec = Vector3()
onready var hurtbox = $Hurtbox/HeadCollision
onready var hitbox = $HitBox/CollisionShape
onready var animation_player = $AnimationPlayer
onready var particles = $CPUParticles
onready var death_timer = $DeathTimer
onready var mesh = $MeshInstance
func _ready():
animation_player.play("floating")
var rng = RandomNumberGenerator.new()
rng.randomize()
animation_player.seek(rng.randf_range(0.0,3.0))
animation_player.stop()
func _physics_process(delta):
@ -37,7 +36,6 @@ func _physics_process(delta):
func get_slapped(slap_level, slap_kill, slap_vector):
if slap_level >= slap_kill:
animation_player.stop()
direction = slap_vector * slap_level
hurtbox.disabled = true
hitbox.disabled = false
@ -47,4 +45,12 @@ func get_shot(hitboxOwner):
die()
func die():
particles.emitting = true
hurtbox.disabled = true
hitbox.disabled = true
mesh.visible = false
death_timer.start(3)
func _on_DeathTimer_timeout():
queue_free()

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=14 format=2]
[gd_scene load_steps=15 format=2]
[ext_resource path="res://Scripts/HitBox.gd" type="Script" id=1]
[ext_resource path="res://Scenes/Enemy.gd" type="Script" id=2]
@ -29,55 +29,36 @@ radius = 1.53964
[sub_resource type="SphereShape" id=9]
[sub_resource type="Animation" id=10]
length = 0.001
tracks/0/type = "value"
tracks/0/path = NodePath("MeshInstance:translation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ Vector3( 0, -0.5, 0 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("MeshInstance:scale")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ Vector3( 1, 1, 1 ) ]
}
[sub_resource type="SpatialMaterial" id=13]
params_billboard_mode = 3
particles_anim_h_frames = 1
particles_anim_v_frames = 1
particles_anim_loop = false
albedo_color = Color( 0.952941, 0.109804, 0.545098, 1 )
metallic = 0.25
metallic_specular = 0.98
emission_enabled = true
emission = Color( 0.501961, 0.152941, 0.462745, 1 )
emission_energy = 4.61
emission_operator = 0
emission_on_uv2 = false
refraction_enabled = true
refraction_scale = 0.05
refraction_texture_channel = 0
[sub_resource type="Animation" id=11]
resource_name = "floating"
length = 3.0
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("MeshInstance:translation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 1.5, 3 ),
"transitions": PoolRealArray( 0.5, 0.5, 0.5 ),
"update": 0,
"values": [ Vector3( 0, -0.5, 0 ), Vector3( 0, 0.5, 0 ), Vector3( 0, -0.5, 0 ) ]
}
[sub_resource type="SphereMesh" id=14]
material = SubResource( 13 )
radius = 0.2
height = 0.4
[sub_resource type="Curve" id=15]
max_value = 2.0
_data = [ Vector2( 0.029703, 1.56592 ), 0.0, 0.0, 0, 0, Vector2( 0.995049, 0.656827 ), 0.472208, 0.0, 0, 0 ]
[node name="Enemy" type="KinematicBody"]
script = ExtResource( 2 )
[node name="MeshInstance" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0 )
mesh = SubResource( 6 )
material/0 = SubResource( 12 )
@ -101,6 +82,23 @@ hitbox_type = 2
shape = SubResource( 9 )
disabled = true
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/RESET = SubResource( 10 )
anims/floating = SubResource( 11 )
[node name="CPUParticles" type="CPUParticles" parent="."]
emitting = false
amount = 25
lifetime = 2.5
one_shot = true
speed_scale = 2.76
explosiveness = 0.18
randomness = 0.19
mesh = SubResource( 14 )
emission_shape = 1
emission_sphere_radius = 1.5
spread = 80.0
gravity = Vector3( 0.1, 0, 0 )
initial_velocity = 1.0
scale_amount_curve = SubResource( 15 )
[node name="DeathTimer" type="Timer" parent="."]
wait_time = 3.0
[connection signal="timeout" from="DeathTimer" to="." method="_on_DeathTimer_timeout"]

View File

@ -102,6 +102,13 @@ reset_map={
]
}
[layer_names]
3d_render/layer_1="world"
3d_render/layer_2="hitboxes"
3d_physics/layer_1="world"
3d_physics/layer_2="hitboxes"
[physics]
common/enable_pause_aware_picking=true