How do I differentiate between an object and an instance?

0 favourites
  • 9 posts
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • If i have an object called "A", with an instance boolean variable called "varA", and i copy it many times in the screen. If i write for example a condition: When "A" is touching another object, set "varA" to true. Why when the event occurs with one of the objects, the var is altered in all of them?

    How can i set the objects to act independently?

  • You need to reference the instance in the event condition. In other words, it will only pick a specific instance if you have a condition for that object. For example:

    [attachment=0:77y8jset][/attachment:77y8jset]

    In this example, when an A hits another A it becomes transparent.

  • Ah, so when the green arrow appears means that im defining behaviors for a specific instance, no?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • But.. in your example "A - Is VarA..." (the second one), there is no possibility of making that event work sepparately for every instance? cause as it is, when varA is true, every "A" in the scenario change its opacity to 20.

  • No, the green arrow means it is a trigger (either a action called at some point, or an action that is triggered once while true).

    In the comparaison done by Sumyjkl , only instances of A that have varA to true will be concerned (If I am not mistaken)

    However I suggest not trying a collision check between two instances of the same object if possible

  • Basically in each event, only instances which fulfill your conditions are affected by the action.

  • Ok, understood the green arrow.

    This is the thing. I have some cages in the stage. They are opened when the player interacts with them, but while they are not opened i want them to play an animation each n random seconds. Like they are static, but sometimes they play a moving animation (cause the caged character is trying to get out). Cage element has an instance boolean var where i see if its opened or not, so:

    · I start a condition. If "Cage opened boolean" is not true --> Wait random (5) -> Play moving animation.

    · After that, i set the object to get back to static animation again and the process is restarted.

    For some reason, that random value is always the same for all cages, like the behavior is working for every cage in the stage at the same time, not taking each one an individual random value to start in different times.

  • The Wait is causing your problem here resulting in all Cages being selected.

    I suggest you use something like a Cage var TimeNextPlay and set it as a random delay equal to time + random delay of your choosing on the start of the layout (for loop through the instances, for example). Then when time < Cage.TimeNextPlay run the animation (providing Cage.opened = false) and also set the next random animation run-time (irrespective of whether Cage.opened = true or false). It takes a while to get used to the filtering of the C2 event system, but it's very powerful when you do get the hang of it.

  • I've done it in a similar way than the one you explain and it works.

    Thank you very much for the support guys.

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