global var scope?

Discuss the ZGameEditor Visualizer plugin for FL-Studio.

Moderator: Moderators

Post Reply
Mic
Posts: 47
Joined: Mon May 30, 2011 8:10 pm

global var scope?

Post by Mic »

This has to be me :-)

In the Ballz example where iX and iY are declared as vars owned by the model, I have created 2 global vars, mX and mY, and everywhere in the xml where iX, iY are touched, I do the same thing with mX and mY.

And it does not work - only getting 1 model instance where there should be 30. Am checking values with RenderText and mX and mY are behaving.

It is behaving as though

CurrentModel.Position.X += 2*App.DeltaTime * (ballsPosition[mX, mY, X_COORD] - CurrentModel.Position.X); //Model.OnUpdate

the model cannot use global vars to set its position, but this does not compute ... global = global, right?

Not sure whether there is enough info here but thoughts appreciated,

Regards,

Mic
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hmm,

Why would you want to use global variables for the instance index to begin with? Doesn't make a whole lot of sense to me ..

Sounds like you currently do have 30 instances, but they all grab the same position data from the Array ( which makes sense if you're not manipulating the global variables from the instances themselves ), so it appears like there is just one. Check the log for the number of spawned Models in your scene.

K
Mic
Posts: 47
Joined: Mon May 30, 2011 8:10 pm

ah with you ...

Post by Mic »

reason I added the global var was that I could swap models in and out using the same update code - instead of adding iX1, iX2, iX3 for each model. But I think you might be right - I do have 30 but they are superimposed - thanks for the tip. Guess I should find another way of easily substituting models!
Post Reply