[Suggestion] Compare Instances of Same Object

0 favourites
  • 12 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • I'm trying to set up some events that compare the conditions of instances of the same object.

    For example, say I have two square instances. For all intents and purposes, they're the same. However, their instances variables may have different values and their coordinates will likely not be the same, and so on.

    I need a way to identify and compare two instances of the same object.

    So, say Square(1) has an instance variable value of 10.

    I need to way to check and see that if any OTHER Square(n) overlaps that Square(1), those OTHER Square(n) instances will have their variable set to 10, as well.

    Hopefully that's clear enough. If not, I'll give a more specific example from the game I'm making.

    UPDATE:

    Here's an example of the kind of feature I'm looking for...

    We have the Pick By Comparison event.

    Object: [select]

    Expression: [...]

    Comparison: < , > , == , =/= ...so on

    Value

    That usually works when comparing two different objects or properties of a single object.

    What I'm looking for would look more like this

    Object: [select]

    Instance one expression or value: [...]

    Comparison: [...]

    Instance two expression or value: [...]

    Because right now, when I'm comparing two instances of the same object, whether by Overlap, Pick By [...], For Each... I'm still running into problems in trying to identify each instance when needed within the larger comparison and testing.

  • [bump]

  • You can use Families for this. It's been discussed before, so there should be as thread you can search on. You pick one as the base object and the second as a family object. Now you have both picked at once.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • blackhornet - Huh. So... Do something like "Pick Family" then "Pick Object Instance In Family"?

    Something like that?

  • No. Have a look at this thread:

    RecursiveLineDrawing

  • Or you can use 'Pick Nth instance' and local variables.

  • Ashley - I've been trying that, but I keep running into issues how how to do...

    -> Pick object instances that meet these two criteria.

    -->> From that selection, further pick from those instances.

    made a suggestion similar to what you're saying on the Facebook group. I'll give it a shot.

    blackhornet - Thank you, sir! As always, you're a tremendous help!

  • Why is that a problem? You can just keep adding conditions to further filter it down.

  • Considering that:

    A: there can only be two objects in a collision, and

    B: the likelihood of of said objects occupying the same point at collision is very small. You can then assume that "Pick closest to" 0x, 0y, and "Pick closest to" layoutwidthx, layoutheighty, would pick each object separately.

  • newt - Hmmm...that makes sense, but I'm having trouble conceiving it in my head as to how I'd do it in C2.

    Anyway, someone suggested I use the tilemap as an alternative. I'm going to give that a shot.

    Ashley - Mighty good question, sir. Heck if I have a good answer. I've been struggling to filter things down, but I suspect that my lack of understanding of all the finer points of how each action and event works (behind the scenes) is making it hard for me see what will or won't work.

    It's rather like when I learned just how For/For Each work. I THOUGHT they worked one iteration each tick. Turns out, as I learned later, they work until done, even if that means several iterations per tick. At least, that has been my understanding of late.

  • newt - Ah! Well, that much makes sense. :)

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