[Solved] Modify instance variable on object

0 favourites
  • 3 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hello !

    I recently bougth Construct2 after tried it for days. I initially develop games in object oriented langages.

    However i got a problem in a specific situation :

    • I got a Bullet Family containing BulletLevel1/BulletLevel2/BulletLevel3
    • Bullet Family and BulletLevelX got a LifeTime Instance Variable
    • When a Bullet Family collide a Wall I decrease Bullet Family LifeTime (it allow me to destroy Bullets after an amount of bounces on wall)

    Problem: The Bullet Family LifeTime i decrease is global to all bullets currently in the game so it decrease all Bullets LifeTime.

    Question: How to modify an Object Instance Variable when we only got the Family of this Object (from an event based on this Family) ?

    Thanks <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Instance variable are specific to instance of object, so there is probably something fishy with your events. Post a .capx or screenshot of events that are problematic. My wild guess: There is a picking problem, and you are not referring the instance you want to decrease in lifetime properly.

  • You're right, it was a picking problem.

    I didnt find any doc about Family Instance Variable and i though that if we modify Instance Variable using a picked Family it modify the global Instance Variable common to all Children Objects of this Family but it was a mistake that came from elsewhere ...

    Thanks I learn more and more about Construct2, Geat tool :)

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