Spawn object along the Path2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By sansparkle

Hello, World!

This is my first post here. I decided to get rid of GDScript scripts and use C#.
I was wondering how to spawn my object along the Path2D in specific points and wrote following method. But this not works. Even code in commented line not spawning objects. Please help me.

private void SpawnOresRandomly()
{
	Curve2D curve = Curve;
	
	for(int i = 0; i < maxOreCount; i++)
	{
		var rnd = new RandomNumberGenerator();
		var points = curve.GetPointCount();
		var ore = (Node2D)pathOre.Instance();
		ore.Position = curve.GetPointPosition(rnd.RandiRange(1,points));
		//ore.Position = new Vector2(10,10);
		var parent = GetParent();
		parent.AddChild(ore);
	}
}