Original Post
I have a flat terrain with walls, and a cyclinder in the middle. I use the following code to make sure the player doesn''t go through them.
// Keep ship in bounds
if( g_pShip->vPos.x < -5.0f || g_pShip->vPos.x > +5.0f || // this applies to the ship ONLY
g_pShip->vPos.y < -5.0f || g_pShip->vPos.y > +5.0f )
{
D3DXVec3Normalize( &g_pShip->vVel, &g_pShip->vPos ); // set ship back
g_pShip->vVel.x *= -1.0f; // the bouncing
g_pShip->vVel.y *= -1.0f; // depends on velocity
g_pShip->vVel.z *= -1.0f;
}
Very crude as you can see, simply stopping the player going so far away from the centre of the play area.
How would I stop the player going THROUGH the cyclinder in the middle?
"I envy you, who has seen it all"
"And I, young sir, envy you, who have yet to see it for the first time..."
- Daniel Glenfield
1st October 2001