Initial Value for Instance Variables

0 favourites
  • 4 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • 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?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

  • 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).

  • Thanks for the tips, DuckfaceNinja and inquiesco. I figured it out.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)