How can I check collisions between the environment and the objects in a platform game that isn't tile based? I want to have "brush" entities like in HL2 hammer, here's an example:
[img]http://i56.tinypic.com/k1ta4n.png[/img]
A red dot is a vertex, the black zones are solid brushes.
I had a great implementation of this in AS3.
I forgot.
For collision I would think you need line intersections, where one line is the slope and the other line is the movement vector of the object.
intersections, lots and lots of intersections. although i've been told that box2d and capsules works too.
[editline]24th December 2010[/editline]
[QUOTE=geel9;26927133]I had a great implementation of this in AS3.
I forgot.[/QUOTE]
ugh.
[QUOTE=geel9;26927133]I had a great implementation of this in AS3.
I forgot.[/QUOTE]
Then why post?
[QUOTE=Dlaor-guy;26929255]Then why post?[/QUOTE]
it's geel9; you shouldn't be expecting anything worthwhile or useful.
Uhh. If you can make a "compiler" that would reduce any shape to convex polygons, I think it would be easy to check for bounding box collisions. Something like subdividing the player's bouding box with a grid and checking if every of those gridpoints is inside a poly.
I did a platformer in as3 at one point, at least basic elements of one, which just checks everything in the collision check list and the player has a circle of collision around him, if it hits a pixel that has any alpha, then it collides, here's a link to it: [url]http://iskuri.mygamesonline.org/FliesE2Php/BattlerTest.swf[/url] (ps: press shift when the mouse cursor is on a bit of the map, and it does something cool).
Well, you could use a layer mask. Although I don't recommend it.
You could just calculate the minimum height that the player can move to every time the horizontal position changes. It wouldn't be such a good idea when you have multiple floors one on top of another though. But then again, you could split the map into zones or use some other trick to handle situations like that.
That or collision detection.
You could probably get away with iterating through all the "obstacles" and "ground" polygons through a list - if the world is big, just divide into areas, etc.
If you're doing collision detection for objects of arbitrary shape, I'd try making a method for each collidable and entity that can collide:
bool IsInVolume(x, y)
Then, check each vertex of the obstacle against the entity and each vertex of the entity against the obstacle. Think: Can you have any collisions in which all verticies of object A are not in the volume of object B [b][i]and[/i][/b] all verticies of object B are not in the volume of object A? The answer is yes, for which this method fails, but is that situation possible (in your game)? (Think of a pungee pit in which you check for collision before impaling and after impaling. The pungee point is never inside the volume, and it is possible for the object to not have any points inside the pungee stick.) If the situation is possible, then I think you'd pretty much have to do line intersections rather than point-in-volume tests...
Then, once you find a collision, you can fetch the line that resulted in a positive collision condition and use a...cross product I think...to determine a normal for "backing out", or if you're pre-computing collision, to attempt to avoid collision by "walking" on the surface.
I think this is what you would use for a hull "trace"...
Try to narrow down/qualify your problem, if at all possible. Maybe "2D hull trace" is a good phrase to Google.
[url]http://www.metanetsoftware.com/technique/tutorialA.html#toc[/url]
I've found this, but it's quite hard to understand
[QUOTE=SupahVee;26935411][url]http://www.metanetsoftware.com/technique/tutorialA.html#toc[/url]
I've found this, but it's quite hard to understand[/QUOTE]
Once you understand how it works, it makes a lot of sense. I helped my friend implement this in our Android game, now we just need to do some physics to have it bounce back
Sorry, you need to Log In to post a reply to this thread.