Sign in to follow this  
EvilNando

beat em up collision detection

Recommended Posts

currently Im designing the collision systems for my levels and I need suggestions

currently my levels are straight and boring I would like to know how to handle more things like irregular terrain something like this:

Photobucket

In other words I would like to have my levels go up and down in many different ways

Also this is a pretty interesting way to make levels a little bit more "organic"
if only they height levels could be somehow appear in a more "smooth" way like a mountain slope or something like that




My current idea is to make an editor where you can lay down line primitives and then in game each character would tests each of the main points of their collision box (top, bottom, left & right) agains each of the line segments that form part of current level

Any ideas?

Thanks

Share this post


Link to post
Share on other sites
An interesting problem indeed. I was slated to work on such a game a couple years ago, although it never got the full green light. We'd pondered on collision detection though, and eventually decided to use our existing 3D system (axis aligned boxes versus polygonal map) to do it.

The idea was trace the 2D floor shapes in the 3D editor, then extrude upward to create walls for the 3D collision boxes to bump into. So in the 3D maps, the angled walls are actually at a funky angle like they look, not by the perspective effect that the art style is designed to look like. However, they are extruded straight toward the screen, not with any visible height like the drawing unless you look at them from a different angle. But when you jump in the game, you add the character's altitude onto their Y position, so they do visually go up, even though in the 3D collision map you wouldn't see it since they'd be coming straight toward the screen. Also when you press up or down on the D-pad to walk, you actually walk at an angle, again mimicking the drawn perspective.

It gets really tricky (especially for the artists) when you go and add multiple floor heights like your second screenshot, but still works. In that shot, the floor would still just be a rectangle from the overhead view. However if you rotate the camera down some, you can see the height of the floors. Or if you add the altitude of the floor to the Y position like the game does with the characters, then you can see the height too. Here's a doodle that hopefully explains it. The first drawing is the overhead view of the collision for the second screenshot. The second is the same map with the camera rotated down (no perspective though) so you can see that the raised areas are actually extruded upward.

Image and video hosting by TinyPic

It would be easier to edit if you wrote a custom editor rather than doing it in Maya like a regular 3D map as we'd planned on. And an editor shouldn't be too difficult to write, since it is only pseudo-3D. The collision system itself could be simplified a lot from real 3D too, due to vertical faces always being perfectly vertical and no sloped floors.

Share this post


Link to post
Share on other sites
wow pretty overkill for a 2d beat em up

considering that golden axe was made in the 80's who know how the heck they made it possible lol

so far I have 2 options


1- the lazy option: take a snapshot of the entire level make it a png can paint blocked areas and make a collision array based on the texture


2- make many lines each should only be of one kind top bot left right
then check all the points on those lines and store the x and y on a collision array (this time a single dimension array would suffice)

3- make an editor to handle rotated rectangles and place them all over the map then in-game check collisions in a AABB manner (sounds good but I fear slowdowns because I cant figure out a proper way to handle the broad-phase check)

need moar ideas guys comeon!

Share this post


Link to post
Share on other sites
Quote:
Original post by EvilNando
wow pretty overkill for a 2d beat em up

considering that golden axe was made in the 80's who know how the heck they made it possible lol

Yeah, but in our defense we only had like 2 months to make the whole game. Not much time to write a new system, much less make an editor for collision maps. Starting from scratch, I really don't think it would be overkill by the time you got all the simplifications in. That's just a good starting point for visualizing what the collision data should be like. It is a 3D problem, however you decide to solve it.

For an editor, I'd do it where you trace the floors on the map with 2D polygons (points connected by line segments). Hold shift to snap to commonly used angles (horizontal, vertical, 45 degrees, and 2-to-1 slope as seen in your second screenshot). Polygons have a flag to set whether they have inside walls (i.e. the main floor versus raised areas).

From there, you need to set the altitude of each polygon, as well as define the actual Y position. See the drawing in my previous post... it all needs to collapse down to a single rectangle if you subtract the altitude of each polygon from its Y position.

I'd do it by having the actual polygon drawn in red, and then you extrude downward and the bottom copy is drawn in cyan or whatever. Then you just drag it down until it lines up with the bottom edge of the wall in the map. Assuming you won't have any floating platforms, then you just find the floor polygon with the highest altitude that is overlapping the bottom polygon of the current platform, and that defines the altitude of the bottom, and implicitly, the actual Y position of the platform (Y position of the bottom edge minus the altitude of the bottom). May as well highlight whoever is declared to be the base altitude, just so you're sure it's all working right.

In the game, you essentially collide a 2D box versus 2D line segments. Always collide against polygons with inside walls, only collide with raised floor polygons if your altitude is lower than they are.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this