0 votes

Hello !
Is it possible to change a variable's value from the animation panel ?

I created a Call Func track, targetted the node with the variable script, then added a key and tried writing this in the 'name' section :

myvariable = 1

it didn't work.
I then tried to put only "myvariable" in the name section, then "1" in the Int Argument section.
but it didn't work either... :P

could you please help me ?

in Engine by (245 points)

1 Answer

0 votes
Best answer

You have two ways of changing variables from AnimationPlayer:

1) Adding export in front of that variable.

This will make the variable accessible from the inspector, and that means you will be able to animate it (which regularly sets this variable when the animation is playing).

2) Making a setter and call it

If you just want to set the variable in a specific point in time, or if you're not keen on exposing it in the inspector, you can create a function to set it, like:

var myvariable = 42

func set_myvariable(value):
    myvariable = value

Then you will be able to call this function with the wanted value using a Call Func track (write the name of the function, add one argument, set its type to integer, and write the value it should have).

by (27,772 points)
selected by
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.