Collision detection and walking around environment

Started by
3 comments, last by moldyviolinist 10 years ago

Hey, I want to add physics and collision detection in my game. At the moment I'm on the subject 'Collision detection' and I need some suggestions. I use XNACollision.cpp/.h from the Direct3D SDK for intersection tests. I need some help, how should I do to test collision between two AABBs and two spheres? I mean should I transform AABB/Sphere to World Space (but that result's into a fatter box) or should I do collision detection in local space of a object? (there are two boxes of two different models, both have their own local space. Should I transform box0 into local space of box1 and do collision detection there? or should I transform box1 into local space of box0 to do collision detection there?). Should I use physics engine for collision? if yes, then which one and what are the basics for becoming familiar with that physics engine?

The last question I put is 'How to walk around environment'? All games have buildings, houses, terrain etc. How they manage to get height of all those objects/environment to walk on it? Should I do ray-casting? (I already have a getHeight(x,z) function in my terrain class but what should I do if a house is on the terrain and I want my player to walk on the stairs and then go to terrace?)

Advertisement


Should I use physics engine for collision?

Yes !


if yes, then which one

This depends on a lot of factors. Most engines already come with a physics engine on board. Physx is popular for AAA titles. I personally prefer bullet (free, eg included in blender). Start with downloading the SDK and play around with some demos.

I also suggest you use Bullet, its fast, has a simple API and is pretty easy to set up. Its also free, which may be good if your on a tight budget. Feel free to PM me if you need some help implementing it into your engine/game!

Ok I will try to use physics engine but how to walk around environment? ray-casting to get height? or optimized ray-casting (divide mesh into octree to only test nearest triangles.)

How do professionals do it? (Walking around buildings, floor, stairs, etc.)

I think ray-casting is probably the best way to do collision detection with terrain or ground meshes. Bullet has a built-in ray testing function (a member of the btCollisionWorld) that should be quite optimized.

This topic is closed to new replies.

Advertisement