0 votes

I am having trouble calling a function from one Node into another. This is the code to call a player clock in a chess game:

print("pausing")
var clock = get_tree().get_root().get_node("Chess/PlayerClock")
clock.get_script().pause_clock()
print("paused")

This is the code in the clock Node

extends Label

func pause_clock():
    print("CLOCK PAUSED!")

The output is simply:

pausing
paused

I also tried

clock.get_scipt().call("pause_clock")

With the same result. Does anyone know why the function is not called?

Steve

in Engine by (14 points)

1 Answer

0 votes

you don't need to call additional get_script()
just try clock.pause_clock()

by (9,754 points)
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 webmaster@godotengine.org with your username.