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

Godot Version



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

var some_var =

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 =

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)


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

1 Like