EragonZZZZ -> RE: Flash Q&A Thread 4 (8/30/2007 21:31:28)
|
Nopes. Not even close :P My system took a lot of mathy stuff and a bit of eyeballing to see if it would work. Thus far, it's pretty damn sweet. However, it's made for an art-based game, so it's based on doing accurate collision detection on VERY irregular shapes. Take Object1 and Object2 (suppose both are longer than they are wide..works both ways, but this is easier to explain) Define 3 coordinates for each: one is the center of the MC, one is the center of the top half, and one is the center of the bottom half. Define 2 radii for each: one is the average of the MC height and width. This number corresponds to the center point, forming a large imaginary circle. The other is: ((obj1.Width + obj1.Height) / 4) * (obj1.Width / obj1.Height). This corresponds to all three points, forming three smaller imaginary circles. Since testing between circles is so easy, all the code proceeds to do is check if the circles are intersecting. I *think* I'll refer to a collision as when four..maybe three...or more little circles (in total) register a 'hit' with a bit circle. Here's a nice little diagram of this in action: Here ya go. I'm aware that this *may* hit trouble with: -Large objects vs small objects -Lag? So far, no stress tests have been run..but early demos show no change in framerate. At all. -Objects that barely fill their alloted volume (dimensions)..think a giant L...ton of blank space :P No stealy my method! jk..but credit if you use it, please? NOTE: So the game doesn't explode, I'm going to use several 'cheats' to make sure EVERY object isn't tested against EVERY object in-game...if you're 1000 feet away, i KNOW you aren't touching me.
|
|
|
|