Ball goes through terrain

arkos

13-07-2006 18:33:52

Hey guys,

I am making a game where the player can through a ball. The ball should obviously bounce off of the terrain, but sometimes (seemingly at random) the ball goes right through the terrain.

I think that the reason for the ball going through the ground is because it is small compared to the polygon it is colliding with. When I make the ball bigger, there are no more errors, however, I obviously can't have a ball that is 4 times the size it should be and I don't want to tesselate the ground much more than it is right now. Does anyone have a suggestion?

I could also turn up the number of physics calcs per second but I already have it at 500 which is way more than I am going to use in the release of the game!

maxwave

13-07-2006 21:47:04

Use ContinueCollision property in body or in material of body - it is specially for this case. :wink:

HexiDave

14-07-2006 00:12:49

If you want to do a hack to save some CPU power, you could also have the game objects (in this case the ball) check a ray straight down to see if it's over your landscape/playing field at all. Maybe check every 500 miliseconds or something to conserve even more cycles, but basically if it doesn't detect any of your playing field under, you can set it to where the landscape really is.

I don't know the context of the game, but if you find that it's not incredibly important to have the ball behave perfectly, you could hack that above stuff in for some extra speed. You could also go as far as to get the physics data (omega, velocity, etc) and after you replace the ball where it should be, you could reset the physics data and let it go like nothing ever happened :D

I did this for a networked game I did just in case the object sunk through the floor or was out of bounds - worked well for me.

arkos

14-07-2006 01:51:34

Thanks for your replies guys,

I got really excited when I read the post about
setContinuousCollisionMode(1), but unfortunately when I went into the code, my partner had already put that in there some time ago. He calls:


body->setContinuousCollisionMode(true);


So I still don't have a clue of how to correct our problem. To give you some background information, we import the playing terrain from maya. It is importated as a static physics body. We call setContinuousCollisionMode(true); on the ball, but not on the terrain ( I don't know if that is a problem or not).

Any other suggestions would be greatly appreciated.

P.S. Hexidave, thanks for the advice, it is a good idea, but we really need realistic skips off of the ground and the extra cpu cost is worth it.