0 votes

Ejemplo: quiero hacer algo como esto, Si la variable a aumenta, la variable b disminuya, It is that I will implement it in an attempt of a catapult system like plants vs zombies

Godot version 3.3.4
in Engine by (42 points)

3 Answers

+1 vote

It's seem like a math peoblem, try to use subtraction or division.

For example:

  1. Subtraction case:
    y = 1 - x, when x in [0,1]

  2. Division case:
    y = 1/x, when x > 0.

Then x increase implies y decrease.

by (526 points)
0 votes

I don't understand spanish. but just from the title of this question : if You want to bind some behavior to change in one particular variable You can use setget keyword.

var _myvar : int setget onvarset
var anothervar : int

code below subtracts one from anothervariable whenever _myvar increases :

func onvarset(value) :
       if value > _myvar :
           anothervar -= 1
     _myvar = value

Setters require some setup to use properly, read about in documentation before You paste this code

by (7,447 points)
0 votes

Lets say you have a variable x and a variable z.
Lets also assume that in the staring state x=200 and z=300.
You take the sum of x and z which is 500 in this case.
If you increase variable x in your code you can make z decrease the same amount x increases by setting z = 500 - x. I don't know which programming language you are using to help you futher but this should give a pretty good idea of what you should do.

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