Initial Value for Instance Variables

Just started using Construct 2? Post your questions here

Post » Wed Oct 01, 2014 3:26 am

When I change the initial value for an instance variable, the dialog changes the initial value for all instances of the same object. I was working on the tutorial "Building a platform game - a beginner's guide". There are 4 instances of the flooring object. When I change the initial values for "floor" and "points" variables, the initial values are changed for all instances. So the last inital values entered are applied to all instances. How do I retain the varied initial values for each unique instance?
B
6
S
1
Posts: 3
Reputation: 395

Post » Wed Oct 01, 2014 3:31 am

EDIT: Oops, I misunderstood your question, sorry! I thought you were wanting to change individual instance variable data on an event. I'll leave the post here though in case that particular tidbit of information helps someone, :).

You can target specific instances and set the variable data using UID.

For example:

** Make a global variable called objCollidedWith **

Player -> On collision with object
-- objCollidedWith = object

object-> Pick instance with UID objCollidedWith
-- sets variable for this instance only
Last edited by inquiesco on Wed Oct 01, 2014 4:43 am, edited 1 time in total.
Founder of Jadelight Studio, Developer of Libertas Aedifex, regular C2 Help contributor and fan of ambient music and Star Wars.
B
12
S
4
Posts: 255
Reputation: 2,008

Post » Wed Oct 01, 2014 4:36 am

winvill wrote:When I change the initial value for an instance variable, the dialog changes the initial value for all instances of the same object. I was working on the tutorial "Building a platform game - a beginner's guide". There are 4 instances of the flooring object. When I change the initial values for "floor" and "points" variables, the initial values are changed for all instances. So the last inital values entered are applied to all instances. How do I retain the varied initial values for each unique instance?

Do not click the object from your project window, click on the individual object on the layout to change them individually.
You can do this via event too by looping foreach object, set instance variable randomly or use array.at(loopindex).
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Wed Oct 01, 2014 4:00 pm

Thanks for the tips, DuckfaceNinja and inquiesco. I figured it out.
B
6
S
1
Posts: 3
Reputation: 395


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest