Godot Version
4.5.1
Question
was trying to implement afterimages of meshes when i dash
func create_afterimage():
if not visuals:
return
var ghost := visuals.duplicate()
get_tree().current_scene.add_child(ghost)
ghost.global_transform = visuals.global_transform
# Stop any active animations
if ghost.has_node("AnimationPlayer"):
ghost.get_node("AnimationPlayer").stop()
# Collect all mesh children of the ghost
var mesh_list: Array = []
for child in ghost.get_children():
if child is MeshInstance3D:
mesh_list.append(child)
# Apply transparent color and start fade
for mesh in mesh_list:
mesh.modulate = Color(afterimage_color.r, afterimage_color.g, afterimage_color.b, 1.0)
var tween :Tween= mesh.create_tween()
tween.tween_property(mesh, "modulate:a", 0.0, afterimage_fade_time)
# Clean up ghost node after fade completes
var cleanup_timer := get_tree().create_timer(afterimage_fade_time)
cleanup_timer.timeout.connect(func():
if is_instance_valid(ghost):
ghost.queue_free()
)
thats the code
the code creates the after images and delets them, but doesnt apply the color not the fading