system
August 29, 2022, 7:04pm
1
Attention
Topic was automatically imported from the old Question2Answer platform.
Asked By
godotuser123
Hello
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
system
August 29, 2022, 7:22pm
2
Reply From:
jgodfrey
You’ll want to use Add()
. See here .
Should I create a class or something?
because its still doesn’t work
godotuser123 | 2022-08-29 19:41
and maybe can u please show me practical use of the method
godotuser123 | 2022-08-29 19:46
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:
segments.Add(10);
jgodfrey | 2022-08-29 19:56
system
August 30, 2022, 1:27pm
3
Reply From:
juppi
Hello.
Here you go:
var array = new Godot.Collections.Array<Node>();
array.Add(new Node());
var list = new System.Collections.Generic.List<int>();
list.Add(1);
list.Add(2);
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.).
Thank you man
I’ll let u know if it worked
godotuser123 | 2022-09-02 06:11