Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411512 Posts in 69376 Topics- by 58430 Members - Latest Member: Jesse Webb

April 26, 2024, 10:10:00 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Question about collision in AS3
Pages: 1 [2]
Print
Author Topic: Question about collision in AS3  (Read 7021 times)
kyn
Level 10
*****


View Profile WWW
« Reply #20 on: January 03, 2009, 03:39:45 AM »

The manbaby thing seems to be creating a lot of misunderstandings :<
Logged
JLJac
Level 10
*****



View Profile
« Reply #21 on: January 03, 2009, 03:44:38 AM »

I did too hate being a manbaby.
Logged
kyn
Level 10
*****


View Profile WWW
« Reply #22 on: January 03, 2009, 03:56:34 AM »

I thought it was funny, and when I found out about the Mancrib I thought it was even funnier
Logged
grizzly
Level 0
*


View Profile
« Reply #23 on: January 03, 2009, 06:58:32 AM »

The manbaby thing seems to be creating a lot of misunderstandings :<
nah, i thought it was funny too. and now that i am no longer a manbaby all is right with the world
Logged
kyn
Level 10
*****


View Profile WWW
« Reply #24 on: January 03, 2009, 11:08:56 AM »

Rejoice, all is right at last Hand Shake Left:D:handshakeR:

Also, collisions in AS3, etc, etc. Please do continue
Logged
grizzly
Level 0
*


View Profile
« Reply #25 on: January 30, 2009, 04:27:22 AM »



oh man, I just bumped into this problem, spent a few hours crawling the net for an answer and then return to the very thread that helped me with AABB collisions in the first place and find the answer. once again, cheers sparky and boris
Logged
raigan
Level 5
*****


View Profile
« Reply #26 on: January 30, 2009, 08:38:29 AM »



In the past I've worked around this (in tile based games) by skipping the checks for sides facing another obstructed tile. So if the left side of a tile faces another filled cell, you can't collide with its left side. It feels like a hack, though.



This is what we used in N, this tutorial has an explanation and code, but it's horrible: http://www.harveycartel.org/metanet/tutorials/tutorialB.html#section2

One BIG problem that should be noted is that this is only a partial solution: it only works for axis-aligned edges. If you have sloping tiles in your game, you'll get the exact same "bumping on seams" problem with a series of sloping tiles whose surface forms a solid line (uh.. hopefully what I mean is clear).

The only "real" solution we've found is to extend the above method to its logical conclusion: take all the individual tiles, consider their explicit geometry (i.e a solid tile would be four linesegments, a triangle would be three, etc) and do some CSG to weld/merge/union them together. That way you'll end up with an explicit, solid, closed representation of the _surface_ of the world, which is what you want to collide with: your floor made of multiple tiles gets merged into a single flat lineseg.

This is definitely doable and not too complicated -- you don't need to bother with a general CSG solution because you're on a grid, so you can cheat (since you know all your verts will lie on a grid, this simplifies things a lot).

Of course, at this point you're doing lineseg-based collision, and really tiles are just a metaphor used by your editor to generate the linesegs. This is what made us switch to lineseg-based editing for the in-development game.. tiles are definitely very powerful and useful, but we wanted to see what it would be like to try something different.

Anyway.. I'm amazed at how many seemingly simple things have no good solution, or no good documented solution anyway.
Logged
bateleur
Level 10
*****



View Profile
« Reply #27 on: January 30, 2009, 01:49:11 PM »

Anyway.. I'm amazed at how many seemingly simple things have no good solution, or no good documented solution anyway.

Although I suspect we shouldn't be surprised.

It's in the nature of things to be complex. Only the way we're taught mathematics during our education leads us to expect otherwise. But that's because the problems we encounter are a sample self-selected for elegance and simplicity.

In the specific case of collisions I've tended to find my code becomes more elegant the less I worry about making it general purpose.
Logged

grizzly
Level 0
*


View Profile
« Reply #28 on: January 30, 2009, 09:07:18 PM »

The only "real" solution we've found is to extend the above method to its logical conclusion: take all the individual tiles, consider their explicit geometry (i.e a solid tile would be four linesegments, a triangle would be three, etc) and do some CSG to weld/merge/union them together. That way you'll end up with an explicit, solid, closed representation of the _surface_ of the world, which is what you want to collide with: your floor made of multiple tiles gets merged into a single flat lineseg.

yeah right, if i'm reading you correctly i was considering this same thing... when setting up the map cycle through the identical axis connected obstacles and setting their base coords to represent one large area... i thought maybe there was a better way but if it's what you guys came up with that's good enough for me. cheers
Logged
raigan
Level 5
*****


View Profile
« Reply #29 on: January 31, 2009, 11:08:11 AM »

The only "real" solution we've found is to extend the above method to its logical conclusion: take all the individual tiles, consider their explicit geometry (i.e a solid tile would be four linesegments, a triangle would be three, etc) and do some CSG to weld/merge/union them together. That way you'll end up with an explicit, solid, closed representation of the _surface_ of the world, which is what you want to collide with: your floor made of multiple tiles gets merged into a single flat lineseg.

yeah right, if i'm reading you correctly i was considering this same thing... when setting up the map cycle through the identical axis connected obstacles and setting their base coords to represent one large area... i thought maybe there was a better way but if it's what you guys came up with that's good enough for me. cheers

Just to be clear, we're not using tiles to collide -- just closed loops of linesegs.

Rather than merging a bunch of side-by-side solid square tiles into a single solid rectangle "tile" (which is what it sounds like you're doing), we're breaking the tiles into linesegs then merging the linesegs.

The difference is that you get a single closed polygon for each "island" of touching tiles -- if you make an "L" shape out of solid tiles, you get a single L-shaped polygon.. if you were merging tiles you'd get two rectangles. Probably it makes no difference if you don't have sloped tiles, but if you do then merging into rectangles doesn't fix the "bumping on seams" problem for long slopes.

The lineseg-based method can be tricky when two tiles share a single corner though.
Logged
DDRtist
Level 0
*



View Profile
« Reply #30 on: February 02, 2009, 08:56:26 PM »

Wow, hadn't checked this for a while. I come back and there's a whole nother page's worth. Awesome guys, thanks. Smiley
Logged
grizzly
Level 0
*


View Profile
« Reply #31 on: February 05, 2009, 04:18:40 AM »

Rather than merging a bunch of side-by-side solid square tiles into a single solid rectangle "tile" (which is what it sounds like you're doing), we're breaking the tiles into linesegs then merging the linesegs.

Ah, I see. Well that is cleverer.
I'm only fusing the tiles together on the y axis as the bumping into corners problem only ever crops up that way for reasons that are beyond me. This has solved the problem but perhaps as you say I'll run into issues when I introduce non-AABB collisions, although I've had a couple of ideas.
Logged
Pages: 1 [2]
Print
Jump to:  

Theme orange-lt created by panic