Find the class name of a script

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

Let’s say I have a script called test_script, and script have something like this :

extends Node2D
class_name Shield

And I have some nodes in the tree. I need to know which node has this script attach to it.
Is there a way to do it ?

:bust_in_silhouette: Reply From: Dlean Jeans

Use is Shield.

if node is Shield:
  damage = reduce_damage(damage)

Omg…so simple. Thanks. It works.

lowpolygon | 2019-12-26 01:27

1 Like