0 votes

in unity we can do this to make an array of a custom class.

 public List<CustomClass> Container = new List<CustomClass>();

but in godot I cant seem to do something equivalent to that I can make an array but not make it use my custom class with it

Godot version 3.3.2
in Engine by (152 points)

Not now,
but it's in new version Godot 4 (GDScript 2) which is under the development.

That's good news and bad news, good it's coming, bad that we don't know when 4.0 releases lol

4.0 should be here any time now! (Mid 2021 is what Juan said in a Twitter post!)

Mid 2021 was desire, but we are already past that and not even alpha is out.
But we might expect that alpha come out soon based on this:

https://github.com/godotengine/godot-docs/pull/5058

Oh ok. Oh well, it's still pretty exciting!

2 Answers

+1 vote

Hi,
godot arrays are allways of type variant, there are no typed arrays.
But that does not hinder you from using it with your custom objects.

by (3,922 points)
0 votes

Groups probably provide similar functionality to what you're wanting:
https://docs.godotengine.org/en/stable/getting_started/step_by_step/scripting_continued.html#groups

by (2,832 points)

Unfortunately no groups would definitely not be ideal for what I'm trying to make, thanks for the reply though.

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.