+1 vote

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 ?

in Engine by (173 points)

1 Answer

+1 vote
Best answer

Use is Shield.

if node is Shield:
  damage = reduce_damage(damage)
by (4,157 points)
selected by

Omg...so simple. Thanks. It works.

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 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 webmaster@godotengine.org with your username.