How do I pick instance of several simultaneous overlaps

0 favourites
  • 6 posts
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • Hello again!

    Once again I find my self in need of help from the ever awesome Scirra community.

    Here`s my problem:

    I need to find a way to pick a specific instance of an sprite from several overlaps. I am trying to create a "laser" which would always set its width according to nearest wall in Shooting direction. (so not just nearest to the player for instance, but the wall that would be hit first so to speak.)

    Problem is that all the instances are hit simultanously so i can`t exactly pick the one which was hit first. I`ll attach sample Capx, that should clarify what I am trying to achieve.

    As always, any help is welcome and thanks in advance!

    here`s Capx: https://www.dropbox.com/s/61a8isd1rg735 ... .capx?dl=0

  • Is this what you're looking for? It's not picking the nearest wall but changing the width of the laser until it just reaches the nearest wall.

    https://dl.dropboxusercontent.com/u/836 ... ick01.capx

    There should be a few laser examples like this on the forum.

  • Thanks Ramones, looks very promising!

    I`ll have to test this in my full project. I think this is going to work well in that too. I am bit worried it makes controls feel bit laggish since I am implementing this in multiplayer environment. On the other hand target should always be between player and wall so it might not be a problem.

    I`ll run some tests

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I tested this out. It works but collisions to other players seems to be buggy. I am guessing its because multiplayer object only updates every other tick and that doesen`t work well with this kind of raycasting. I`ll keep on testing and try to make improvements.

    So.... I am still looking for an answer to original question: "Is there a way to pick specific instance of multiple simultaneous overlaps?"

    Also thank you Ramones, even if I can`t get this to work I learned something new from you.

  • Got it!

    Thanks Ramones your code works perfectly. Problem was my collision system which was flawed. Again thank you for your help Ramones!

  • Cool.

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