minor tweaks and fixed barrel explosion
This commit is contained in:
35
scripts/barrel_explosion.gd
Normal file
35
scripts/barrel_explosion.gd
Normal file
@@ -0,0 +1,35 @@
|
||||
extends Node3D
|
||||
|
||||
@onready var top_part: RigidBody3D = $TopPart
|
||||
@onready var explosion_audio: AudioStreamPlayer3D = $Explosion
|
||||
@onready var die_particles: GPUParticles3D = $dieParticles
|
||||
|
||||
@onready var collision_shapes = [$TopPart/CollisionShape3D, $BottomPart/CollisionShape3D]
|
||||
|
||||
const MAX_LV = 20
|
||||
const MAX_AV = 20
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
var lv_x = randf_range(-MAX_LV,MAX_LV)
|
||||
var lv_y = randf_range(0,MAX_LV)
|
||||
var lv_z = randf_range(-MAX_LV,MAX_LV)
|
||||
var av_x = randf_range(-MAX_AV,MAX_AV)
|
||||
var av_y = randf_range(-MAX_AV,MAX_AV)
|
||||
var av_z = randf_range(-MAX_AV,MAX_AV)
|
||||
|
||||
top_part.linear_velocity += Vector3(lv_x,lv_y,lv_z)
|
||||
top_part.angular_velocity += Vector3(av_x,av_y,av_z)
|
||||
explosion_audio.play()
|
||||
die_particles.emitting = true
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
for i in collision_shapes:
|
||||
i.disabled = true
|
||||
await get_tree().create_timer(1).timeout
|
||||
queue_free()
|
||||
Reference in New Issue
Block a user