Terrain + Camera Collision

Started by
1 comment, last by X5-Programmer 17 years, 4 months ago
Hello. Camera setup = overhead camera + zoom( character in the center ). What Im up to is, making an camera collision agains the terrain, so If any collisions appear the camera will decrease the zoom to the player, so the camera not moveing ohter the terrain. How would you handle this? I tryed to make some sort of sphere collision test. dVector tTerrainPos = pWorld::GetCurrentWorld().GetTerrainPos( tCamPos ); dVector tPos = ( tTerrainPos - tCamPos ); float len = sqrt( tPos.x + tPos.x * tPos.y + tPos.y * tPos.z + tPos.z ); float range = 10.0f; if( len > ( range * range ) ) { push the sphere up and decress the zoom to player } And when the Roll goes upwards the zoom will increase again to the orginal zoom view. Feel free to give me pointers on how you would do it (or already have done it) or if you have any other tips on how to make an camera like this. Thanks!
-[ thx ]-
Advertisement
I treat it as just a plain sphere...

One important thing though, is rather than instantly rolling and zooming the camera when it hits ground; I use springs to pull it towards the player vs ground constraints.

this helps to smooth camera motion out; so getting near obstacles doesnt cause jerky and confusing camera changes...
Hello.

I will be glad to hear it in more in detail how you did it you if have time.

Thanks!
-[ thx ]-

This topic is closed to new replies.

Advertisement