accurate 2d collisions ?
Community Forums/General Help/accurate 2d collisions ?
| ||
Hello, I am making a 2d game with a top down view, and i am not really used to work with only images and pixels for collisions detection/repositioning... My current idea is to have 2 "levels" of colliders/collidables. The first level will be inaccurate and fast with a distance check between point (turningmoving entity) and lines (walls) and point (turningmoving entity) and points (obstacles, others turningmoving entities). The second level will be accurate and slow with an intersection check between oriented rectangle pixels (movement vector with radius) and lines pixels (walls) and oriented rectangle pixels (movement vector with radius) and circles pixels (static obstacles, others turningmoving entities). What i wonder is : -how to oriente, scale, an oriented rectangle in 2d. -about the collision detection repositioning of characters/bullets : if i detect a collision between a turningmoving entity and a static entity, how to know how much to move the turningmoving entity so that it does not go through the static entity but at the same time is near enough and does not appear to have a radius of collision around it (or maybe i should not care about being too accurate because the player will not notice it anyway ?) -about the collision detection of a weapon held in the hand of a character : i plan to do a 2 levels check for this : a distance check between point (weapon) and points (obstacles, others turningmoving entities), then if near enough an intersection check between weapon pixels and character/obstacles pixels... -would it be easier to use textured flat meshes ("sprites") without bilinear filtering ? (so that i can capture and read precise colors) (easier to oriente shapes this way, and i can still capture the world to analyze the pixels) Any suggestion is welcome, Thanks, |
| ||
ImagesCollide2 in bmax is quite powerfull. Do a quick check first. |
| ||
(I use Blitz3d) I have not found all the answers yet, but i think that i will use 3d textured flat meshes without bilinear filtering and with a top down view so that it is easier to turn move entities, to detect collisions, to reposition the entities, etc... |
| ||
In blitz3d there is a command for pixel perfect collision; can't you just use it? |
| ||
Are you wanting to find collisions between unrotated pixel images (in which case the imagescollide function will do what you need) or are you wanting to find pixel perfect (or close to it) collisions between rotated pixel images (more difficult)? |
| ||
As i said, i will use flat meshes which turn move on 2 axis to detect collisions, it is easier and more accurate this way (i can turn move a mesh as i want) |
| ||
Maybe this tutorial can help: http://www.ragestorm.net/tutorial?id=22 The C code has been ported in Monkey, too: http://www.monkey-x.com/Community/posts.php?topic=3571 I used that code in a library called OpenB2D, some years ago. |