Bounding Sphere/Box or Another Method for my Terrain

This topic is 4882 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Guy's ive been working on this for awhile here and still yet a little bit new to doing things of this nature so please bear with me .. I have my terrain setup to read my bmp heightmap into my engine and im using 2 textures with alpha blending via a shader onto my terrain. all works fine with the terrain but now I want my player model to follow the terrain. So what i was thinking and after alot of reading is that I would need to create a Bounding Sphere or Box around the player model or around the terrain which is it? I would imagine I would do this around my player and my terrain so that I can do collision detection on the two but the player should always be touching the ground unless jumping around so im not sure how this all would work. I can handle doing the collision detection I have setup a few scenario's where I have 2 cubes they slide into each other from random distances and once they touch it fires off a message to the screen. just for practice. well thats bout all thanks for your responses ..

Share on other sites
You'll want the bounding box to be around your player. You'll need to modify your terrain engine so that you can request a height (y) value at any given x,z coordinate. Then you just move the player's feet to that location.

Example:

int NewHeight = MyTerrain->GetHeightValue(playerX, playerZ);
MovePlayerFeet(NewHeight);

It's a rather simple concept. The more difficult part is getting the y value of the terrain, because x & z are floats and they may be between two vertices. You'll have to interpolate between the vertices. How to do this part will vary depending on who you talk to.

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 11
• 13
• 9
• 11
• Forum Statistics

• Total Topics
634091
• Total Posts
3015433
×