Advanced collision detection discussion
Advanced collision detection discussion
#2
Posted 20 November 2009 - 07:37 AM
#3
Posted 20 November 2009 - 08:23 AM
In .NET it is a built in function (rect.Intersect(otherRect)), but it should be fairly easy to code manually.
This post has been edited by Aurel300: 20 November 2009 - 08:24 AM
#4
Posted 20 November 2009 - 09:53 AM
#5
Posted 20 November 2009 - 11:23 AM
I was thinking of possibly at some time adding in per pixel for the tiles if the sprite does collide with an impassable tile, just checking in those cases would reduce the amount of time spent processing per pixel collision.
To make it a bit better I might go with a bounding rectangle for the sprite and for the tiles, since they are somewhat rectangular, create a smaller rectangle for them and check collisions between those two rectangles to allow the sprite to get closer to the edge of the tiles. At the moment though what is important is that the sprite can't enter impassable tiles.
For character/object collision detection, like NeoTife said, it is usually better to do per pixel collision. It is frustrating for a player if the object just misses them and it counts as a hit. Though when they are playing against the computer and there is near miss that counts as a hit they never seem to complain.
#6
Posted 20 November 2009 - 12:04 PM
I donīt say you should have just ONE boundary box around the whole sprite - maybe there are going to be some bigger ones than 1x1 tiled - like a big dragon or something.
But for those 1x1... Do as you want, but without a good code some performance may be gone.
#7
Posted 20 November 2009 - 12:15 PM
Another common 2D collision detection technique is to use polyogns that are the exact shape of the sprite. The performance remains about the same as rectangle collision. Granted, polygon collision detection is not always a feasible option...
#8
Posted 20 November 2009 - 12:21 PM
#10
Posted 20 November 2009 - 06:49 PM
#11
Posted 20 November 2009 - 08:37 PM
Is this in your tutorials in somewhere else?Cause i realy want to look at it.
Thanx again for all your efforts.
That's realy nice of you SixOfEleven like always you help us so much.
Is this in your tutorials in somewhere else?Cause i realy want to look at it.
Thanx again for all your efforts.
#12
Posted 21 November 2009 - 06:35 AM
If a player is walking over the tile and the hasWalkMap is false, none collision detection is done. However, if the value is true, then the walkMap determines the walkability.
I think that player would have just a normal boundary box and it will be tested for collision with the polygonal walkMap.
Plus, maybe a value "walkable" (boolean) would be needed too. If a tile isnīt walkable, no collision detection is needed either, and this thing would probably be used for water and things like that.
This post has been edited by Aurel300: 21 November 2009 - 06:37 AM
#13
Posted 21 November 2009 - 08:07 AM
The way my collision layer works is when the player is moving, I don't check anything if the player isn't moving as that would be a waste of processing time, check which tile they are moving into using a bounding rectangle. Depending on which direction the player is moving depends on how the collision detection works. The collision layer returns the enum for the tile the player is walking into. At the moment I only have two values in the enum, passable and unpassable. The method that preforms the collision check returns true if the tile is unpassable and false otherwise. I have been considering, if the tile is unpassable, going further and doing a per pixel collision detection between sprite and tile. That would be very far off in the future though.
#14
Posted 21 November 2009 - 09:31 AM
NeoTifa, on 20 Nov, 2009 - 04:53 PM, said:
Hitboxes darling, they are used
TF Hitboxes w/ Anti-Lag applied

ET Hitboxes

etc.
This post has been edited by RudiVisser: 21 November 2009 - 09:34 AM
#16
Posted 21 November 2009 - 12:06 PM
Might be manageable in 2d games but there are definitely better ways.
If you want accurate results, use simplified collision meshes. For things like headshots, just use hitboxes (as Rudi mentioned).
Edit: Also, NeoTifa you realize you might want to use a bounding box/sphere to see if a bullet is reasonably close to the player and THEN do some more expensive collision checking to see if it's a headshot (for example)?
This post has been edited by Tom9729: 21 November 2009 - 12:08 PM
#18
Posted 21 November 2009 - 02:26 PM
Aurel300, on 21 Nov, 2009 - 04:53 PM, said:
With per-pixel CD, wouldn't you have to render everything (even if it isn't being shown on the screen)?. That would be incredibly slow. Also how would you handle objects that are occluded by other objects? Just because the pixels are overlapping on your screen doesn't mean that the objects they represent are colliding.
This post has been edited by Tom9729: 21 November 2009 - 02:26 PM
#19
Posted 21 November 2009 - 04:53 PM
Tom9729, on 21 Nov, 2009 - 04:26 PM, said:
Yes, having to render everything and then check for collisions would be very slow. Having to render everything in the game whether or not it is on the screen, especially in 3D, can be very slow and suck up performance of the game. I guess that is why there are so many good line of sight methods out there.
You have another good point there as well about the occlusion of objects by other objects. If you had two objects in relatively the same position and the object collides with both of them, in pixels, how would you handle that?
#20
Posted 21 November 2009 - 05:03 PM
It seems like a lot of people are moving away from bounding boxes since they are not accurate, and the tend to get stuck. Capsules fit much more closely and are great for sliding collision.
This post has been edited by lesPaul456: 22 November 2009 - 01:25 PM

Start a new topic
Add Reply





MultiQuote



| 


