How do I pick objects intersecting a line?

Get help using Construct 2

Post » Sat Jun 18, 2016 3:29 pm

I have a character aiming in any direction. I want to pick all objects intersecting a straight line from the character.

I could use colission detection and raycaster, but the problem is that for optimization purposes I only want to turn on collision detection for objects in the bullet trajectory, just before the bullet is fired.

Or could I pick within an angle or small cone from the player?
Follow my progress on Twitter
or in this thread Archer Devlog
B
40
S
17
G
17
Posts: 977
Reputation: 12,626

Post » Sat Jun 18, 2016 3:35 pm

You can use line of sight with a very small cone of view, and change the angle to the bullet angle.
Image ImageImage
B
169
S
50
G
173
Posts: 8,313
Reputation: 110,270

Post » Sat Jun 18, 2016 4:14 pm

newt wrote:You can use line of sight with a very small cone of view, and change the angle to the bullet angle.


Even if it returns true or false, it's not picking the obstacle, or maybe I'm doing something wrong?
Follow my progress on Twitter
or in this thread Archer Devlog
B
40
S
17
G
17
Posts: 977
Reputation: 12,626

Post » Sat Jun 18, 2016 4:23 pm

You can fire a fake raycaster object - I do this with a few projects.

You make a bullet object the fires *super fast* before your shot to measure targets and solids.

It's basically an invisible bullet that fires at a hugely fast velocity - then use that data to return some info.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
83
S
34
G
40
Posts: 3,032
Reputation: 30,474

Post » Sat Jun 18, 2016 4:31 pm

newt wrote:You can use line of sight with a very small cone of view, and change the angle to the bullet angle.


And also, LOS, seems to be based on collisions, so not detecting obstacles with collisions off. I need a way to pick objects in a straight line from the player, without the use of collisions.
Follow my progress on Twitter
or in this thread Archer Devlog
B
40
S
17
G
17
Posts: 977
Reputation: 12,626

Post » Sat Jun 18, 2016 4:33 pm

Image ImageImage
B
169
S
50
G
173
Posts: 8,313
Reputation: 110,270

Post » Sat Jun 18, 2016 4:41 pm

newt still lightning fast on the draw...

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
83
S
34
G
40
Posts: 3,032
Reputation: 30,474

Post » Sat Jun 18, 2016 4:43 pm

newt wrote:https://dl.dropboxusercontent.com/u/666516/picklinosight.capx


Ahhhh. that seemed to work. I need to try it out, in my project. Thanks.

I was using has line of sight to, x, y position.
Follow my progress on Twitter
or in this thread Archer Devlog
B
40
S
17
G
17
Posts: 977
Reputation: 12,626

Post » Sat Jun 18, 2016 5:21 pm

newt wrote:https://dl.dropboxusercontent.com/u/666516/picklinosight.capx


@SoldjahBoy

Image

We're getting closer, but i think I have to write something custom with events. Larger objects will fail to detect, or if you are close to objects. I need to detect based on the Bbox, and not the XY, so back to the drawing board, and play with events.
Follow my progress on Twitter
or in this thread Archer Devlog
B
40
S
17
G
17
Posts: 977
Reputation: 12,626

Post » Sat Jun 18, 2016 6:42 pm

@SoldjahBoy
@newt

Image

I managed to solve it finally.

dtAim is the distance to the center line between two imagepoints of the player.
if the distance to the center line is less than a certain ammount(in this case less than the obstacle widht/2, pick those objects.

Now i'm just gonna filter out objects based on distance, and objets behind the player.
Follow my progress on Twitter
or in this thread Archer Devlog
B
40
S
17
G
17
Posts: 977
Reputation: 12,626

Next

Return to How do I....?

Who is online

Users browsing this forum: Artcadev and 23 guests