Can't get multiple Explosions to run simultaneously

Godot Version

4.5

Question

I got objects to explode with add_child explosion but I can’t get two or more objects to explode at the same time. It will only play after each one is finished. The explosion scene got shader material from its mesh.material, set as override_material, and is run by tween.

explosion.scene

func activate():
smoke_mesh.visible = true

### GET/SET SHADER MATERIAL OF EXPLOSION
var mat = smoke_mesh.mesh.surface_get_material(0)
smoke_mesh.set_surface_override_material(0, mat)


### TWEEN ANIMATION AND SIZE
var tween = create_tween()

tween.tween_property(smoke_mesh, "visible", true, 0)
tween.tween_property(mat, "shader_parameter/intensity_2", 0.0, 1.0)
tween.parallel().tween_property(smoke_mesh, "scale", Vector3(8, 8, 8), 1.0)
tween.tween_property(smoke_mesh, "visible", false, 0)
tween.tween_property(mat, "shader_parameter/intensity_2", 1.0, 0.1)
tween.parallel().tween_property(smoke_mesh, "scale", Vector3(1, 1, 1), 0.1)
tween.tween_callback(death)

Green Object.scene

func explosion_death():
visible = false

### DISABLE COLLISION
area3d_collision.set_deferred("disabled", true)

### ADD EXPLOSION TO EXPLOSION_POSITION
var explosion = preload("res://VFX/Explosion_Smoke/Explosion_Smoke_Set.tscn")
var explosion_instance = explosion.instantiate()
explosion_position.add_child(explosion_instance)
explosion_instance.position = global_position
### ACTIVATE EXPLOSION_SMOKE
if is_instance_valid(explosion_instance):
	explosion_instance.activate()

When shoot at first green object the smoke tween will play while second or third green objects will not until the first one is finished.

I’ve tried set local_to_scene and/or duplicate() smoke material but made no different / wrong.

### GET GET/SET SHADER MATERIAL OF EXPLOSION
var mat = smoke_mesh.mesh.surface_get_material(0)
var mat_unique = mat.duplicate()
smoke_mesh.set_surface_override_material(0, mat_unique)

Your code is formatted incorrectly and doesn’t have any indentation making it hard to read

tweens have a parallel mode. When you turn it on, the tweens will run at the same time.

@that_duck

I what I meant was the explosion should happen whenever I destroy the green object. Although I have now fixed it.

The solution :

Because the explosion is a tween of a shader material in the explosion scene and each added_child explosion is the same instance of one another I need to make that shader material unique every time it is activated, so I was using duplicate().

My original try was correct but dumb me forgot to plug in the duplicate() var into the tween.

func activate():
smoke_mesh.visible = true

### GET GET/SET SHADER MATERIAL OF EXPLOSION
var mat = smoke_mesh.mesh.surface_get_material(0)
var mat_unique = mat.duplicate()
smoke_mesh.set_surface_override_material(0, mat_unique)


### TWEEN ANIMATION AND SIZE
var tween = create_tween()

tween.tween_property(smoke_mesh, "visible", true, 0)
tween.tween_property(mat_unique, "shader_parameter/intensity_2", 0.0, 1.0)
tween.parallel().tween_property(smoke_mesh, "scale", Vector3(8, 8, 8), 1.0)
tween.tween_property(smoke_mesh, "visible", false, 0)
tween.tween_property(mat_unique, "shader_parameter/intensity_2", 1.0, 0.1)

@athousandships

Sorry I didn’t realize the format it must’ve remove the tabs somehow when I tried to apply this thing </> *actually the box automatically removes the tabs when I paste my code into it. It won’t allow me to re-tab either so I have no idea how to fix it.