**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

+1 vote

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

For example:

Subtraction case:

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

y = 1/x, when x > 0.

Then x increase implies y decrease.

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

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.

- All categories
- Engine 34,019