Instance Variable

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

    I've used 'instance variables' a few times, but I still don't quite understand it.

    Can I use instance variables in this situation to re-use the object 'Sensor_1:'

    by giving it the variable instance property?

    <img src="http://1.bp.blogspot.com/-dvSZkNbrvvQ/UfFFcJDHBTI/AAAAAAAAAB8/hzExzoCgpDI/s1600/Untitled-2.png" border="0" />

    I'd like the sensor object to do different stuff depending on which instance Player collides with. How do I check which instance of Sensor_1 Player is in collision with?

    Thank you

  • Instance variables are used when you want a piece of data to be unique to an instance. In other words, if you have 10 sensors with an instance variable called "range" (for example), each sensor can have a different value for "range".

    When a player object collides with a sensor, C2 will pick the specific instance(s) of sensor that collided with player. If you then access the sensor's instance variable, it will be specific to that sensor.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you.

    So, making many new objects called Sensor_1 Sensor_2 etc is ok?

    I have a kind of Construct-Anxiety with this kind of thing. I'm always worried that adding too many objects will 'slow it down'. (Am I just being supersitious?)

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