0 votes

I mean, as far as I know, you need to do that:

var class = preload("class.gd")

func _ready():
   if object extends class:

Isn't there another way? One that doesn't need to allocate a variable to check against?

in Engine by (1,120 points)

1 Answer

0 votes
Best answer

There is no way of doing that without loading the class.

However, you should use const instead of var, this way the class won't be fetched for every instance of your script.

Note: preload doesn't loads the resource everytime, it does it only once when the script is loaded, and embeds a reference to that resource wherever you store it (var or const).

by (29,090 points)
selected by
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.