How to add slope velocity?

Blitz3D Forums/Blitz3D Beginners Area/How to add slope velocity?

Guy Fawkes(Posted 2012) [#1]
Hi all! :) Can someone please point me to a *SIMPLE TO USE* function, which allows for me to both calculate & prohibit my player from going any higher if the player's angle is greater than or equal to that of a steep slope (and use a parameter such as Function CalcSlope(player, 45.0)? Etc, etc...

Thank you! :)


Floyd(Posted 2012) [#2]
Assuming you are using Blitz3D collisions then you have the components of the collision normal. CollisionNZ() tells you angle you need.

ACos( CollisionNZ() )

is the angle of "steepest ascent" relative to horizontal. That would be 0 if the terrain ( or whatever ) is horizontal at the collision point, 90 if vertical.

If the angle is greater than you want to allow then don't go up any more.


Guy Fawkes(Posted 2012) [#3]
I understand most of that, but how do I allow them not to go up. I want them to sorta slide back down slowly if they reach the slope's maximum velocity angle?


Guy Fawkes(Posted 2012) [#4]
?


Floyd(Posted 2012) [#5]
Oops. I reverted to my mathematical training and mixed up my letters. In mathematics it is traditional to have Z pointing up. But in Blitz3D it is Y that points up. So when I mentioned using CollisionNZ that really should have been CollisionNY.


Imagine a rod stuck in the ground perpendicular to the surface. This is the collision normal. The steeper the hill the closer this rod is to being horizontal. You recognize that by the Y component being small. If ACos( CollisionNY() ) is bigger than your desired maximum angle then you don't go up any more.

If you then want to go back down what direction should you move? Again, visualize that rod perpendicular to the ground. Imagine you are directly above the rod, looking down. You see the rod pointing downhill. The horizontal components X and Z give the direction to move.

You move around in the world by changing X and Z, with Y being whatever the ground level happens to be. The "downhill" direction is the two dimensional vector given by CollisionNX() and CollisionNZ().