Jump to content
  • Advertisement
Sign in to follow this  
ScreamingDoom

3D Collision Detection with Isometric Sprites

This topic is 3156 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was playing X-Com the other day and became curious as to how the collision detection works with firing weapons. My first thought was that they first found the tile which crossed a projected ray then used a mask to get per-pixel detection on whatever object is sitting on the tile, but projectiles can actually go behind objects (like walls or soldiers) so this can't possibly work. My other thought was that they basically split each tile in half above the top "far" point of each tile and test the X, Y, and Z components of the weapon ray against three different bitmasks (everything on the left hand side is considered to be on the Y-Z plane, everything on the right is considered to be on the X-Z plane and everything on the tile itself is considered to be on the X-Y plane). In a full 3D environment, this would be easy, but how on earth do you do it in a 2D isometric sprite-based way in which there is no real 3D object information? I couldn't find any articles on it.

Share this post


Link to post
Share on other sites
Advertisement
In xcom and most games the graphics and collision detection are handled separately. Xcom has its map data arranged in a 3d grid and traces a bresenham line between two points.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kaze
In xcom and most games the graphics and collision detection are handled separately. Xcom has its map data arranged in a 3d grid and traces a bresenham line between two points.


Okay, but how does it determine what part of the sprite collides with the ray being used for collision detection? Do all the potentially collidable objects also have a set of voxels or other 3D data associated with it which are used to actually determine if a laser blast actually hits something?

How is the program able to go from a 2D sprite of a solider, alien, or piece of scenery and determine how it relates to 3D coordinates?

Share this post


Link to post
Share on other sites
Quote:
Original post by Kaze
The map objects all have height values but to so some extent the hit detection in xcom just isn't that accurate and I think the placement of fatal wounds is completely random.


So objects in X-Com have a 3D collision box that is associated with the sprite? Or do they do a pixel-collision test on the X-Y coordinates of the sprite and the Z coordinate is just a constant that is associated?

Share this post


Link to post
Share on other sites
I think it uses a extremely simplified collision box that takes advantage of all the game objects being locked to one square in the map grid. Basically all it has to do is create a list of all the squares a projectile will pass through and test for walls, floors if it changes a level and map objects if their height is greater than the bullet height. Other than enemies that are shorter than a map cube it views the entire cube as a valid hit area.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kaze
I think it uses a extremely simplified collision box that takes advantage of all the game objects being locked to one square in the map grid. Basically all it has to do is create a list of all the squares a projectile will pass through and test for walls, floors if it changes a level and map objects if their height is greater than the bullet height. Other than enemies that are shorter than a map cube it views the entire cube as a valid hit area.


Neat! Thanks for the explanation!

I presume that there are multiple hit boxes possible for things like windows and fences that you can shoot through?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!