AltParty2024/scripts/shape_dance.gd

33 lines
1.1 KiB
GDScript3
Raw Normal View History

2024-10-01 17:29:36 +03:00
extends Node3D
@export var amount: int = 2;
@export var offset: float = 2.0;
@export var shape_shader: Shader;
@onready var path: Path3D = $Path
@onready var shape_material: ShaderMaterial = ShaderMaterial.new();
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
$Camera3D.make_current();
shape_material.set_shader(shape_shader);
var path_length: float = (path as Path3D).get_curve().get_baked_length();
for i in range(amount):
var instance: PathFollow3D = PathFollow3D.new();
var mesh_instance: MeshInstance3D = MeshInstance3D.new();
mesh_instance.mesh = BoxMesh.new();
mesh_instance.set_surface_override_material(0, shape_material);
mesh_instance.set_instance_shader_parameter("id", i);
print("kaka" + str((mesh_instance.get_surface_override_material(0) as Material).get_shader_parameter("id")))
instance.add_child(mesh_instance);
path.add_child(instance);
instance.set_progress_ratio(offset / 100 * i);
#print(instance.progress_ratio);
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass