add projectile destroy effect
This commit is contained in:
@@ -11,7 +11,8 @@ func _ready() -> void:
|
||||
|
||||
func init(start_position: Vector3, direction: Vector3 = Vector3.ZERO) -> void:
|
||||
global_position = start_position
|
||||
look_at(global_position + direction)
|
||||
if direction != Vector3.ZERO:
|
||||
look_at(global_position + direction)
|
||||
|
||||
|
||||
func _on_finished() -> void:
|
||||
|
||||
@@ -8,6 +8,7 @@ const MAX_STRETCH: float = 0.75
|
||||
|
||||
@export var _collision_debug_material: Material
|
||||
@export var _hit_particles_scene: PackedScene
|
||||
@export var _destroy_particles_scene: PackedScene
|
||||
|
||||
var _start_position: Vector3
|
||||
var _velocity: Vector3
|
||||
@@ -67,6 +68,15 @@ func set_velocity(velocity: Vector3) -> void:
|
||||
_life_timer = _lifetime
|
||||
|
||||
|
||||
func _destroy() -> void:
|
||||
var destroy_particles := (
|
||||
_destroy_particles_scene.instantiate() as Particles3DSelfDestructing
|
||||
)
|
||||
get_tree().get_root().add_child(destroy_particles)
|
||||
destroy_particles.init(global_position)
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_body_entered(node: Node3D) -> void:
|
||||
if node is Player:
|
||||
queue_free()
|
||||
@@ -77,11 +87,11 @@ func _on_body_entered(node: Node3D) -> void:
|
||||
if node is CollisionObject3D:
|
||||
var collision_node := node as CollisionObject3D
|
||||
if collision_node.collision_layer & 1:
|
||||
queue_free()
|
||||
_destroy()
|
||||
return
|
||||
|
||||
if node is CSGCombiner3D:
|
||||
var collision_node := node as CSGCombiner3D
|
||||
if collision_node.collision_layer & 1:
|
||||
queue_free()
|
||||
_destroy()
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user