Picking Question

0 favourites
  • 5 posts
  • Hey there everyone, as the title states, I have a picking question...

    I've got multiple instances of my object, and they all have a private variable, this variable is a different value for each instance, now, when two instances are next to each other, I need to make them average out their values with each other, and this needs to work for as many as their might be side by side.

    if I have 3 instances (with their values showing) arranged like so:

    7, 6, 2...

    I need to have them all check with each other and become:

    5, 5, 5...

    any ideas?

    Overlap at offset detects the side by side instances, but after that I can't seem to find a good way to select them, the instances are also created and placed randomly, so UID's are no good...

    Thanks in advance.


  • Just wondering, is there a way to call for the UID of an object I'm detecting at offset? As I understand it, Overlap at Offset only picks the object that is checking for the overlap, not the object overlapped as well, if I could return the UID of the object being overlapped, then I could make it work

  • Have you tried "pick nearest"?

  • No because there will be cases where there will be multiple instances that could be considered "nearest" at the same time, I need more precise control than that. I appreciate the reply however :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • http://dl.dropbox.com/u/5426011/examples15/average_values.capx

    You can tweak how you define what side by side by changing the "select" sprite or tweaking event 4.

    If you want to have only touching sprites count as side by side then make "select" have the same image as "sprite". Or if you want to do a distance calculation instead change event 4 to:

    Pick all sprite

    For each sprite

    distance(select.x, select.y, sprite.x, sprite.y) <= 100

    If you can pick an object you can get it's UID. In the case of your question you could save the uid of the object to a global var, check for overlapping at offset, and then use an inverted pick by uid to make sure you don't pick the original. That may not work in this situation of checking for objects of the same type, so you may want to use a detector object as I have in the example.

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