Instance IDs, spawning instances with different PV values

This forum is currently in read-only mode.
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • First things first, I'm fairly sure that the answers to my questions can probably be found somewhere in the forums, a tutorial, or the wiki, but my best efforts haven't turned up anything. But I won't be offended if an answer is a link to a resource, hah.

    Here's my problem: I have an object with a lot of private variables that I'm tracking. I want to spawn different instances of this object, and I want to control what the values of those PVs are for each individual instance as it spawns.

    Example: Let's say I've got a "wave object" with the private variables speed, momentum, and volume. When this wave collides with a rock, I want to spawn a second wave with all of the same properties and whatnot, but with different speed, momentum, and volume values.

    My second question is more general: Where can I learn more about how Construct handles referencing instances of the same object? How does it know which instance I'm referring to when I have an event that does something to an instance of an object? Is there a way that I can grab a value from a specific instance without grabbing from the others? Etc. I basically just want to educate myself in this area a bit more, because I'm instancing a lot of objects and I anticipate having more questions.

    Thanks in advance!

  • http://sourceforge.net/apps/mediawiki/construct/index.php?title=Conditions

    You have to filter the SOL (selected object list) with condition picking. Imagine all the instances start out picked, and each condition eliminates instances from the sol which don't return true on the condition.

    For setting pv's when spawning, it depends on what version of construct you're using. In all versions, you add a spawn object action, then a set variable (or any other action) right after it, and it will pick only the spawned instance. Be careful with multiple spawning of the same insance in a single event:

    in 98.9

    You cannot put multiple spawn+set events in a single event or subevent and expect it to correctly pick and set each object's pv. To have multiple spawns of the same instance with different pv settings each time, you must make subevents (with just an ALWAYS condition for instance) for each one.

    in 99.42

    you can have multiple spawn + set events in a single condition, and it will pick the last spawned sprite.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Just realized I forgot to actually thank you!

    Yes, this information definitely helped me work that out. Thanks a lot, Davio.

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