0 votes

I am looking for a way to increase (and decrease) values in a variable.
For instance, I have a variable and I want to have the variable to fluctuate in it's values to cause different things inside a script. Because of that I will have its initial value as0. When one thing happens, I want to add the varuable's value from a 0 to a 1 or another integer that I would like. And vice versa; subtracting the value of the variable from a 1 to a 0 or from a 0 to a -1.

If anyone know how, I would deeply appreciate it.

in Engine by (83 points)

1 Answer

+1 vote

Have you used another programming language before? GDScript works most languages when it comes to this:

var x = 0
# increment x
x = x + 1  # x is now 1
# this does the same thing
x += 1     # x is now 2
# decrement
x -= 1     # x is now 1

The basic overview of GDSCript is a good place to start: http://docs.godotengine.org/en/2.1/learning/scripting/gdscript/gdscript_basics.html

by (21,920 points)

Thank you very much! I had an idea of how it works but I didn't quite get how it worked :/
Thanks anyway!

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 [email protected] with your username.