Godot Version
4.2
I am attempting to have my character controller emit an explosion when it fires a projectile. The explosion has a smoke animation, which I would like to inherit the inertia from the character controller, so that the smoke keeps moving in whatever direction the player was moving at the point they fired a projectile. The problem is, the explosion_instance is a mesh(not a rigidbody), so I can’t apply velocity in a simple way.
I have tried updating a global variable “global_velocity”(of the character) in the physics_process, and then applying that to the explosion_instance in it’s own function.
Also, in my emit_explosion function, I am parenting the explosion_instance to a childnode(explosion_point) of the character controller, which I assumed would at least bind its position to the character controller, and allow it to move with the character.
In all cases, I am unable to get the explosion_instance to move after it emits. Instead, the animation plays and it stays at the place i instance it.
Below is the structure of my explosion emission function. I have removed any attempt to move it or set its position. Any feedback is much appreciated, whether general ideas or actual code. Thanks!
func emit_explosion(explosion_point, _delta):
var explosion_instance = explosion_scene.instantiate()
explosion_point.add_child(explosion_instance)
#define instance to delete it later
explosion_instance_to_delete = explosion_instance
#check for existing instances
print("explosion count: ", explosion_point.get_child_count())
#access the AnimationPlayer node of the explosion instance
var animation_player = explosion_instance.get_node("AnimationPlayer")
if animation_player != null:
animation_player.play("explode")
# Start a timer to remove the explosion instance after a delay
var explosion_timer = $explosion_Timer
explosion_timer.start()
#delete explosion instance after timeout
func _on_explosion_timer_timeout():
#var _delta = get_process_delta_time()
print("timer end")
explosion_instance_to_delete.queue_free()