Finding the Gradient

Blitz3D Forums/Blitz3D Programming/Finding the Gradient

Aries(Posted 2004) [#1]
Hi
My game is in the 3rd person view and what i want to is to find out the gradient of the piece of mesh which collides with the man. When the man walks up to a steep part of the mesh (when the gradient gets past a cetain height) then move the man back down the slope.

One way of doing this is to set the collisions response to slide1. But this isnt much help, as when the man goes up to any height he slides down.

If anyone could tell me how to find the gradient it would a lot of help.

thanks for your relpy
Aries


poopla(Posted 2004) [#2]
You need to analyze the collision normals.


Stevie G(Posted 2004) [#3]
This may help ..

When the man collides with the mesh - get the collision normals with ..

nx#=collisionnx()
ny#=collisionny()
nz#=collisionnz()

then ..

AlignToVector man,nx,ny,nz,2,0.25

If you can't get this to work, Ross C posted something a few weeks ago with code to demonstrate - check out some old posts.


poopla(Posted 2004) [#4]
The man... always trying to get ya down! Sorry couldnt resist ;).


Mr Snidesmin(Posted 2004) [#5]
I had this problem to solve too for my own 'walking-around a terrain thingy'. I came up with a simpler solution though:

Instead of finding gradients, I had the guy walking by progressing with small jumps (steps) in a gravity field.
The height of a step/strength of gravity and the forward speed will lead to a maximum gradient climbable.

it's difficult to work out what the max gradient will be, but you can fiddle with the values to get the desired effect.

A cool side effect is that the guy kind of realistically jumps and bounces his way down slopes.


Shambler(Posted 2004) [#6]
Try this, may have to adjust it depending on your world scale.

Do a linepick straight down then

If PickedNY#()<0.75 Then TranslateEntity player,PickedNX#()*(10+Rnd(5)),-1.0,PickedNZ#()*(10+Rnd(5))


adjust the 0.75 to the minimum steepness you want the player to fall down.