+1 vote

I've been trying to use the append method in my array but it doesn't seem to exist
(I think my declaration is right)

public int[] segments

all I want is to add entries at the back of the array

in Engine by (38 points)

2 Answers

+1 vote
Best answer


Here you go:

var array = new Godot.Collections.Array<Node>();
array.Add(new Node());

var list = new System.Collections.Generic.List<int>();
list.ForEach(i => GD.Print(i));

The Godot Array is best for Godot Types (Nodes, Textures, etc.) and the .NET List is good for everything else (float, int, string, etc.).

by (1,075 points)
selected by

Thank you man
I'll let u know if it worked

0 votes

You'll want to use Add(). See here.

by (19,238 points)

Should I create a class or something?
because its still doesn't work

and maybe can u please show me practical use of the method

Sorry, I don't have access to a Mono build of Godot ATM to do any testing, but it should work exactly as expected.

Based on your initial snippet above, I'd expect this to work:

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 Frequently asked questions and 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 [email protected] with your username.