Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm working on making a 2D isometric engine in Java. I'm getting into collision detection and I've hit a bit of a problem.

Characters in-game are not restricted to movement from tile to tile - they move freely. My problem is that I'm not sure how to stop a player from colliding with, say, a crate, without denying them access to the tile.

For instance, say the crate was on .5 of a tile, and then the rest of the crate was off the tile, I'd like the player to be able to move on to the free .5 of the tile instead of the entire tile becoming blocked.

The problem I've hit is that I'm not sure how to approximate the size of the footprint of the object. Using the image's dimensions don't work very well, since the object's "height" in gamespace translates to additional floorspace being taken up by the image.

How should I estimate an object's size? Mind, I don't need pixel-perfect detection. A rhombus would work fine.

I'm happy to provide any code you might need, but this seems like a math issue.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

You'll need to provide data (or explicit code) specifying the object's floor size. There's really no way for code to automatically figure out, for an isometric image, what portion of the image is flat on the ground, and what portion is vertical -- you'll need to specify that information yourself.

On the other hand, it's a fairly common thing to just treat the whole area encompassed by an object as unwalkable. If you allow the player to walk behind a large crate (for example), it's easy for him to go out of view, and no longer to know what's going on. So you might be able to just get away without doing anything special, if you're happy to do that.

share|improve this answer
    
I was afraid that might be the case. I really don't like the idea of making it entirely unwalkable, because that limits my ability to do things like archways or anything like a standing column, etc. –  BattleBarnes Jan 17 '13 at 3:56
    
That said, its easy enough to define the shape of the footprint of, say, a crate, using the two faces pointing towards you and then drawing parallel lines for the two hidden faces. Is there some way of doing something like that with Java? –  BattleBarnes Jan 17 '13 at 4:02
    
You're getting into the realm of machine vision, there, trying to get the computer to recognise shapes within an image and extrapolate. I suspect it'll be substantially easier to just tell the computer how big the object is. :) –  Trevor Powell Jan 17 '13 at 4:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.