# Legacy GMInstance variable logic problem

G

#### Gsti

##### Guest
Ok is very simple, I have an object with this in create event:
Code:
``acc_y = -8;``
and this in the step event:
Code:
``````if (acc_y < 12) { acc_y +0,25}
y = y + acc_y;``````
Now i thought that the istances of the object didn't share the internal variables. When I spawn one moster his speed will be like +5, but if i spawn another one while the first one is still in the room, their acc_y get add to the other so they start to fall faster than they should. Is there something i'm missing?

G

#### Gsti

##### Guest
I have even tried with id.y or self.y
But nothing changed

#### Toque

##### Member
Not exactly sure what your trying to do but the statement has a comma ,25 Did you mean .25?
I think your logic is off but not exactly sure what your trying to do.

They shouldn't share instance variables.
The code is

acc = -8

if (acc < 12) {acc +.25} this is true so it will just add .25

y = y + - 7.75;

I dont think Y can have a decimal point?

Last edited:
G

#### Gsti

##### Guest
They shouldn't share instance variables.
That's what i thought. I rewritten the code, this is why i used 0,25 and not 0.25. Anyway you have to understand that the acc decrease is in the step event, this means that every step the speed of the object will increase of 0.25
y = y - 7.75 | y = y - 7.50 | y = y - 7.25 | and so on. But if I have 2 instance of the same object they work like this:
With one instance of the object:
y = y - 7.75 | y = y - 7.50 |
When the other instance enter (or is spawn) in the same room:
y = y - 7.00 | y = y - 6.50 | y = y - 6.00 |
I'm telling you that the increase of the accelleration sum up from 2 different instances of the same object

N

#### NeonBits

##### Guest
I don't know...
step event:
acc_y += 0.25;
if (acc_y < 12)
{y += acc_y;}
Maybe set acc_Y to 0 instead of -8 in create event?