How to select only the object that's touching the player.

0 favourites
  • 11 posts
From the Asset Store
Surena Touch
$1.25 USD
50% off
A wrap from official Touch plugin to export touch/mouse input to other plugins.
  • To expand on the Title; If I have multiple of the same object, how do I target (to change the animation of and take the X/Y of) ONLY the instance of the object that is touching the player?

  • 'on collsion' or 'on overlap' (found in the sprites conditions) selects the player as well as the overlapping sprite(s).

  • Yeah, but does it target only the single instance of the object that's overlapping? Or won't all of the objects be selected? My situation is that I have duplicate instances of the same object (copy+paste in the editor for now), and I want to select ONLY the one that is overlapping. And then I should be able to retrieve that object's X/Y.

    TL;DR I'm pretty sure that still targets all instances, not just the one. I can't test it currently, since I'm not at a computer.

  • I'm sure the action only happens to the one that intersects with the player however just to be sure you can include a

    Player X is overlapping Object

    statement and might as well include other actions in there like the object's animations, other properties...

  • Yeah, I'll try a few things later and respond back with an answer (just in case others are interested in this too )

  • It only targets one. <img src="{SMILIES_PATH}/icon_mrgreen.gif" alt=":mrgreen:" title="Mr. Green">

    https://www.dropbox.com/s/8qrjcsmp2oxka ... .capx?dl=0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah, but does it target only the single instance of the object that's overlapping?

    'on collsion' or 'on overlap' (found in the sprites conditions) selects the player as well as the overlapping sprite(s).

    All sprites that, on the moment of checking, overlap the other sprite. Meaning, if you got multiple sprites overlapping, you mostly should use 'for each sprite'. Or combine it with a pick condition that filters some more.

    None overlapping sprites are not selected.

    'on collisions' Is bit different in the sense that it is a trigger. Triggers can happen multiple times in a tick. It happens collision by collision. So it sets objects 1 by 1 selected.

  • It only targets one. <img src="{SMILIES_PATH}/icon_mrgreen.gif" alt=":mrgreen:" title="Mr. Green">

    https://www.dropbox.com/s/8qrjcsmp2oxka ... .capx?dl=0

    Modified your capx to clearly show things.

    https://www.dropbox.com/s/t3k86hn7dxeqi ... .capx?dl=0

    (hope it was ok to be lazy, you did most of the work allready)

  • No problem, 99Instances2Go, but it seems the capx file is identical to the one I uploaded earlier. Haha!

  • Ty for pointing that out ! Updated link. Now out looking for a brain.

  • Ty for pointing that out ! Updated link. Now out looking for a brain.

    You're welcome, 99Instances2Go. Oh, yes. This example is better than mine.

    (I should have mentioned the player had to move around to overlap sprites..)

    I'll try always upload the method that doesn't require the player to move around in the future. I think it's much better this way.

    Thank you, 99Instances2Go.

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