How do I pick instance of several simultaneous overlaps

Get help using Construct 2

Post » Sun Dec 27, 2015 4:58 pm

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
B
25
S
7
G
4
Posts: 31
Reputation: 4,798

Post » Sun Dec 27, 2015 6:06 pm

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.
B
55
S
28
G
19
Posts: 1,520
Reputation: 25,540

Post » Sun Dec 27, 2015 7:23 pm

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
B
25
S
7
G
4
Posts: 31
Reputation: 4,798

Post » Sun Dec 27, 2015 10:08 pm

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.
B
25
S
7
G
4
Posts: 31
Reputation: 4,798

Post » Thu Dec 31, 2015 6:33 am

Got it!

Thanks Ramones your code works perfectly. Problem was my collision system which was flawed. Again thank you for your help Ramones!
B
25
S
7
G
4
Posts: 31
Reputation: 4,798

Post » Thu Dec 31, 2015 2:55 pm

Cool.
B
55
S
28
G
19
Posts: 1,520
Reputation: 25,540


Return to How do I....?

Who is online

Users browsing this forum: Exabot [Bot], Phacanu and 12 guests