0 Favourites

How do I pick instance of several simultaneous overlaps

  • 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:

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • 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.

    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

  • 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)