collision point

Discussion and feedback on Construct 2

Post » Mon Jun 22, 2015 5:20 am

If you want to go the racasting route, here's an example with a re-usable raycaster event group that I've been using. It only needs the Function object to copy over.
https://www.dropbox.com/s/qfjyoluo4eo83 ... .capx?dl=0

To use set the start and end points of the ray with "raycast.set ray".
Then call "raycast.cast to" with the endpoints of every line segment you want to cast to.
Then use the functions "raycast.get x", "raycast.get y" to get the collision point or the end of the ray line segment if no collision occurred.
Last edited by R0J0hound on Mon Apr 03, 2017 9:06 pm, edited 1 time in total.
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Mon Jun 22, 2015 6:05 am

@jobel you might be misinterpreting my capx a bit. It does use 'is overlapping' but the whole thing is wrapped in a function call that you could call how often you want. Also even if all your objects are dynamic the list feature still significantly improve performance since it all happens in an instant.

@r0j0hound thanks for the capx! looks very neat!

I wonder if the mathematical method could be even slower than the iterative method in larger layouts (with thousands of collider objects) due to the inability to use the collision cells feature?
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,679

Post » Mon Jun 22, 2015 6:30 am

@sqiddster
It may be slower than iterative methods since calculating intersection points isn't too cheap. With many objects it would be a problem, so any techniques to cull objects you don't need to cast to should help. The main use I have for it is to find an exact point of collision, and also the angle of the edge hit (although that's not present in the capx).
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Wed Jun 24, 2015 4:22 pm

@sqiddster right okay,that makes sense.. I was thinking it was doing it all the time because of how you call it in your capx example. It's a little overkill for what I'm working on right now.. I have little fighter ships that are doing "fly bys" and peppering the player with a little auto-laser beam (not a continuous beam). But I am implementing a "laser drill" next that I will probably need something like your capx.

@R0J0hound oh that's interesting, so you are basically defining the collision poly with imagepoints..nice! wow, that does seem a brute force method..but it could come in handy on big sprites where I need the hit coordinates..although in that same line of thinking what if I had 8 image points..I wonder how costly that would be performance wise...
B
97
S
32
G
16
Posts: 1,199
Reputation: 16,680

Post » Wed Jun 24, 2015 9:57 pm

@jobel
With 8 instead of 4, then with one ray it would do twice as many intersection tests.
In general if there is no culling, the number of intersection test will equal=
(number of rays) * (number of image points)

So if you increase either then the amount of time will increase proportionally.
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Previous

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 23 guests