Built in scripts and usage 'is' expression

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DavidPeterWorks

I have built in script in Catcher. I have sepeareted script for Bunny.
I got an error because Catcher is a packedScene. Bunny is a script.
How can I use ‘is’ expression with built-in scripts?

var Bunny = preload("res://Scenes/Bunny.gd")
var Catcher = preload("res://Scenes/Catcher.tscn")
#I have no .gd for Catcher.

    if (myObject is Bunny or myObject is Catcher):
       doThigns()

You declared a variable as var Bunny. What is that Const.Bunny? What is Const in other words?

johnygames | 2019-08-04 10:43

Fixed. Removed Consts.

DavidPeterWorks | 2019-08-04 10:48

:bust_in_silhouette: Reply From: johnygames

Just remove the Const part from your code and it shall work.

The question is about the “is” expression and packaged scene with built-in scripts.

DavidPeterWorks | 2019-08-04 18:36

Try using the == operator instead of the is keyword.

johnygames | 2019-08-04 18:41