Walking on a mesh

Blitz3D Forums/Blitz3D Programming/Walking on a mesh

Moraldi(Posted 2007) [#1]
I have a character walking on a mesh loaded with the LoadMesh command. In order to avoid climbing on hills and mountains I need to know how much is the mesh slope on character's position. does anybody knows how to read this slope?

Thanks in advance


Rob Farley(Posted 2007) [#2]
Do a line pick from your player to the mesh below, then get the normal.

You could probably get away with just dealing with the NY however, I would suggest writing the values out on the screen and walk around and work out what the limits should be.

http://www.blitzbasic.com/b3ddocs/command.php?name=LinePick
http://www.blitzbasic.com/b3ddocs/command.php?name=PickedNX
http://www.blitzbasic.com/b3ddocs/command.php?name=PickedNY
http://www.blitzbasic.com/b3ddocs/command.php?name=PickedNZ


MadJack(Posted 2007) [#3]
Another option is to split the level into two meshes - terrain vs walls (steep bits). Make the terrain mesh walkable, the 'walls' unwalkable in your collisions.

However if your level geometry is 'seamless' this might not be a suitable approach.


Moraldi(Posted 2007) [#4]
MadJack: My geometry is imported from FreeWorld and it is much more work to add invisible 'walls'. I will try ¿'s approach


Stevie G(Posted 2007) [#5]
Z approach is best - you can achive the same effect with standard Blitz collisions too.

You only need to test to see whether collisionny() > .25 ( or some other figure between 0 and 1 ) to allow movement.

Stevie


Moraldi(Posted 2007) [#6]
¿'s solution works exactly as I wanted. Thanks to all!