0 votes

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);
    }
}
Godot version 3.2.3
in Engine by (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.