Gravity on a Mesh Terrain

Blitz3D Forums/Blitz3D Beginners Area/Gravity on a Mesh Terrain

Mattizzle(Posted 2007) [#1]
http://thewyldturkees.com/game/Blitz_Gravity_Help.zip

Hello all. For the last couple of weeks I've just been making random stuff to learn about and experiment with blitz. So here I have a .3ds terrain mesh made in FreeWorld3D textured with one collapsed image (of the texture splatting done in FreeWorld3D.) I've been working on gravity recently and I would like to know if I'm coding it anywhere near to a standard... it seems to simulate pretty well but I have one major problem: If you stand still, you'll notice that the downward gravity is being triggered even though I've asked it nicely to not push down when your on the ground. I'm using an invisible cube to act as the feet of the camera. The "feet cube" is used as the trigger for gravity when there's no collisions with the terrain. If you "un-comment" the line that sets the cube's alpha to 0, you'll be able to see the cube in action.

So. All coments welcome. If I'm totally off on this whole gravity simulation thing, please tell me a better way! :-P

Thanks,
Matt

PS -
";#Region and ;#End Region"
Is a feature of Protean (a 3rd party blitz IDE) that lets you collapse areas of your code.


Sledge(Posted 2007) [#2]
While I'm slowly downloading this (56k, see) I'm going to bet myself a nice cup of tea that you've got sliding collisions on.


Sledge(Posted 2007) [#3]
Thought so! Here's an intermediary solution, although you may have to give the wider system a bit more thought (depends on whether you're happy with air acceleration still being generated when stationary). I've included some bits of original code around the new snippet so you can see where to insert it...



Now. I owe myself a brew.


Mattizzle(Posted 2007) [#4]
Thanks, dude! Unfortunately it's still shaking abit when you stand still on an almost-flat slope... Is there a better way to simulate 1st person player gravity and air acceleration?


Buggy(Posted 2007) [#5]
I'm a little confused, but I'd suggest just changing the Collisions line. The "Collisions" command has several parameters, and one lets you not make things on slopes go down.


Mattizzle(Posted 2007) [#6]
Yes that may work, but if you're standing on an 80 degree slope, it would not be very realistic to not slide down and only be balanced by air...


Sledge(Posted 2007) [#7]

Unfortunately it's still shaking abit when you stand still on an almost-flat slope... Is there a better way to simulate 1st person player gravity and air acceleration?



Here's a simplified (in that you'll have to build your original control scheme/mouselook back in... curs keys only from me!) model that won't shake but will simulate gravitational acceleration along the y axis (toddle off the edge to see)...



Now if you want inertia along with that, that's another system and should be handled separately I think. I notice in your original that you apply air acceleration to cx and cz... I would restrict it to affecting y.

Also, if you want the player to slide only at certain (extreme) inclines then that will involve a 'pick' downwards, interpreting the vector of the 'picked' geometry and setting the collision rules accordingly (sliding or not). I have only concentrated on the shaking issue.


Stevie G(Posted 2007) [#8]
Mattizzle,

I think changing the collision rules in the main loop is probably asking for trouble .. never really tried it myself so could be wrong.

You could roughly determine the slope angle by checking the average collisionny() . Basically the closer it is to 1 the flatter the land is. If you keep the sliding collisions and only apply gravity if collisionny() < .5 or suchlike.

Alternatively you could get the actual pitch vector by getting the average of the collision normals and then Incline# = VectorPitch( aNx# , aNy# , aNz# )

Stevie


Mattizzle(Posted 2007) [#9]
wow thanks for all the help everyone! i think learning how to find where the camera is on the mesh terrain by collision will be the best thing i'll learn from this thread!

thanks!

ps - im typing this with a psp :-P