Hi guys,
i was wondering what is the easiest way to do collision between terrain and a player controlled model? i want the model to be able to move around on the terrain and for its Y value to change depending on the height of the terrain.
I would prefer not to use a physics engine because i have never used one before, but if i HAVE to which would be easiest to integrate?
Thanks in advance for any help
collision between nodes
-
- Competition winner
- Posts: 1123
- Joined: Sun Jun 10, 2007 11:14 pm
Well, first of all, I'd recommend a physics engine despite what you said. Getting integrated will not be too difficult, and it's faster and more accurate than the irrlicht collision. If you're absolutely against that, try looking at the tutorials. If you don't want that either, you can cast a ray down from the character and on to the terrain and set the height to where the ray hits.
-
- Posts: 288
- Joined: Wed Oct 29, 2008 12:07 pm
If you just want to prevent a player from going through the map on your terrain you can make a heightmap and set the players slightly above the height map on the given (x,y) coordinate. That way he will always be above it and it would take a few lines of code. You need an ITerrainSceneNode* for it though.
Thanks for the help guys,
@Lonesome Duck i have just downloaded the Bullet Physics engine, but from looking through the tutorials i dont feel all that confident with implementing it, i will take a look at ray casting though thanks.
@Alpha Omega i have tried using the GetHeight function to keep my model above the Terrain but when i add a jumping mechanic it keeps the model anchored to the ground thats why i am opting for a different method. thanks for your help any way
@Lonesome Duck i have just downloaded the Bullet Physics engine, but from looking through the tutorials i dont feel all that confident with implementing it, i will take a look at ray casting though thanks.
@Alpha Omega i have tried using the GetHeight function to keep my model above the Terrain but when i add a jumping mechanic it keeps the model anchored to the ground thats why i am opting for a different method. thanks for your help any way