Silly Question, why can't I instantiate certain native classes?

Godot Version

4.2.1

Question

I’ve written out the following code, within the body of a script function:

var some_var = Rect2i.new()

This triggers the error “Cannot find constant “new” on base Rect2i”

But there is such a constructor on Rect2i (and supplying args for the other constructors gives the same error).

Meanwhile, this code, in the same function, works fine:

var random = RandomNumberGenerator.new()

What am I missing here?

notice randomnumbergenerator class has object inherited
while rect2i doesnt

the new() is exclusively Object’s method

Ohhh, wow, ok that makes sense. How do I get a Rect2 then? Can’t?

just Rect2i(parameters)
image

2 Likes

Hahaha ok. Sheesh that’s counterintuitive. Thanks so much for the help!

1 Like