DEV Community

Cover image for How to get a variable value from another script, Godot's Visual Script
Archer Allstars
Archer Allstars

Posted on • Edited on

1 1

How to get a variable value from another script, Godot's Visual Script

Update: Godot's Visual Script will discontinue in Godot 4.0. Therefore, it's useless to continue using Visual Script in Godot now.

A lot of people who use Godot's Visual Script want to get a variable value from another script. Here's how!

Just drag and drop a scene node, which is attached to the script, into the canvas as shown in the screen recording below:

drag and drop a scene node

A proper way to do it

As it has been pointed out in my previous tutorial, it's better to use an instance mode unless you are OK to fix every nodes if anything goes wrong.

  • First, set a scene node that you want to get the variable from to an object variable in the _ready function which will be called only once.

set a scene node

  • Change set mode of the node to Instance. And put the object variable to the instance input port.

setup

I hope this helps 👍


Cover photo by olieman.eth on Unsplash

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay