walking up slopes

Blitz3D Forums/Blitz3D Beginners Area/walking up slopes

rtk(Posted 2008) [#1]
How would you make a character walk up slopes? I am making a FPS and I set the collisions between the player and the terrain as follows:

Collisions 1, 2, 2, 3
Collisions 2, 1, 2, 3
UpdateWorld()
ClearCollisions

But I can't seem to walk up even the smallest hills. The terrain and buildings are type 2, and the player is type1.


Dreamora(Posted 2008) [#2]
Don't set the collision 2 way. Only player against terrain (sphere vs polygon) and sliding type (up and down)

thats it and it will work.

2 way collisions will break it.


jfk EO-11110(Posted 2008) [#3]
2 way collision is only needed when both objects are moving.

Sphere or Ellipsoid versus Polygon for Player vs Landscape as Dreamora said. You'll need some gravity that will push down the player if the slope under his feet is steeper than a certain angle. You may use a linepick towards the ground to determine the angle.


Whats My Face(Posted 2008) [#4]
A good way to do gravity is to only apply it if you aren't touching the ground that way you can walk steep slopes and have acceleration due to gravity rather than just a uniform falling speed.


jhocking(Posted 2008) [#5]
That does have the problem though of making your downward movements stuttery because gravity will keep turning on and off every other frame.

Frame 1: touching the ground so don't fall, move forward
Frame 2: floating in the air so fall
Frame 3: touching the ground so don't fall, move forward
Frame 4: floating in the air so fall
etc etc etc

I forget, is there a way of dealing with this?


Danny(Posted 2008) [#6]
good question.
Perhaps when moving forward also apply like 25% of gravity downward - to make sure the entity 'sticks' to the ground??

D.


Ross C(Posted 2008) [#7]
I'm pretty sure what i did was to apply a constant force downwards. As in real life, gravity is constantly affecting everything. :o) If you set your collision mode correctly, you shouldn't have any problems walking up slopes. I also use a linepick to determine whether the player has ground under his feet, so if he walks off a ledge, the fall animation can play and real gravity comes into play, instead of a small downwards force.

The linpick can also be used to stop the player walking up angles that are too steep.


jhocking(Posted 2008) [#8]
when moving forward also apply like 25% of gravity downward

Oh right, duh. Instead of turning gravity off completely, just make it weak when colliding with the ground.


rtk(Posted 2008) [#9]
Thanks, you guys were helpful.