XNA Creators Club Online
Page 1 of 1 (2 items)
Sort Posts: Previous Next

Terrain/Level <--> Player collision algorithm

Last post 5/25/2008 11:54 PM by Antony Kancidrowski. 1 replies.
  • 5/25/2008 9:42 PM

    Terrain/Level <--> Player collision algorithm

    Hey all,

     Just started my game engine and need to make collisions with some terrain/level stuff, I can draw it just fine, but I can't figure out how I should do my collisions. I thought I would make collision models for my objects(in maya) and then export them out to my game, and before I wasted to much time I thought I'd ask: Would making the collision models out of several meshes, and then giving each of the meshes bounding boxes/spheres/frustums and colliding with those work? I know the unreal engine has a DOP collision bound type collision system, but for my system, that's a bit extensive.

    So essentially here's my idea:

    foreach (ModelMesh mesh in model.meshes) 
       foreach (ModelMesh Pmesh in Player.model.meshes) 
       { 
          if (mesh.boundingsphere.Intersects(Pmesh.boundingsphere)) 
              //Tell the Engine 
       } 

     

    Do you think it would work?

    -Chris

  • 5/25/2008 11:54 PM In reply to

    Re: Terrain/Level <--> Player collision algorithm

    Using the bounding sphere for collision detection is quite common and works just fine.
    Ant.
Page 1 of 1 (2 items) Previous Next