Tips on collision Detection
PurulentSoftware
Member Posts: 15
Anyone know a better way of doing collision detection because a box doesn't work very well for game characters and animations.
Comments
I wonder if you could make shapes out of a series of rectangles and spheres and constrain them together to make the desired collision shape? That's basically all they do in AAA titles anyway.
Might be worth an experiment.
In a game I'm working on now I have a small ball that is set to collide with different objects and then destroy itself if it hits certain objects. I also have a collision rule to collide with itself. If I "shoot" one ball off in say a nice slow high arch and then another after it in a fast straight line and the 2nd one collides with the 1st, they are about 3-4 times their own width away from each other when they collide. Visually, that looks like crap and that scenario could very well happen in my game.
I guess I'll try creating a hit area that's actually a clear image whose X & Y position is (I guess) constrained to the X & Y position of the ball and whose size is considerably smaller and play around until I get a more visually realistic result.
AFTER FURTHER REVIEW--- ID Ten T Error
I had the size of the ball wrong in the actors size attributes. Loaded a new image and have the correct size and it works correctly. Oops.
It is two fold. Detects better and dramatically increases performance.
1. The first part is nothing new just use invisible actors as collisions.
Its easier than it sounds . You make little squares and name them something like col1, col2, col3. Your actor will then spawn them. If the actor is static its really easy because you dont need to constrain anything.
If it moves pull the collisions actors over to y our field and make them visible. Rotate them around until you parts of the square poke out where you need.
No matter what size you make the collision point if you can make the middle of it cross the middle of your actor you can constrain it or them to your actor. I lay every thing in a blank field so i can do everything over the little x. Its not scientific but for me i prefer visual.
2. If you are just using a non scrolling screen and have lots of non moving actors just make one background image with all of them rather than seperate actors all with collision fields. You can then place invisible actors all over you back ground image.
From testing i can tell you that one 480x320 image and 20 actors with no image at all performs better than 20 actors with a 128x128 image all out at the same time.
This cuts back on performance and size an in turn saves loading time.
1 2 3
4 5 6
7 8 9
I originally drop the collision actor in the scene say in space #3 and my actor that I'm constraining it's position to is in spot #8. When I hit preview, it appears to now be in space 8 like it should be, but the collisions are occurring like it's still in #3. I took a 2 hour break and now think I need to find some green beer.
just makes it better to not miss something easy.
I actually gave up. Its not that big of a deal as the actor doesn't move until the very end of the level and by that time, there won't be any more collisions. It's just weird though. Since I'm probably going to have roughly 40 to 50 levels by the time the game is ready for release I was hoping I could just do it quick and dirty. Now I'll just have to make sure the collision actor is placed exactly where I need it. I guess all in all, it'll add just a few minutes over a few weeks of total development time. I've probably spent more time posting in this thread then it'll take to drop the actor exactly where it needs to go in 40 or 50 levels.
So if, for example, you have an object constrained to the mouse, it will stay constrained to the mouse even if you drag it through walls, etc.