FPS stair climbing...

Blitz3D Forums/Blitz3D Programming/FPS stair climbing...

JA2(Posted 2007) [#1]
I was wondering if anyone could help me out with this. I have my FPS camera and a set of stairs, and I'm doing the usual linepick straight down to work out the cameras Y position.

What I'd like to do is have the camera 'bounce' slightly on each step rather than just snap to picked Y position. Hope that makes sense :)




IPete2(Posted 2007) [#2]
JA2,

I don't know how it will help, but maybe you could use the diminish function from the code archives, this allows you to send a variable out and it always returns to zero, by altering the variable by whatever smaller amount you want per frame. So stuff could be reduced by .01 or 1 or etc.

It also works on negative and positive variable valuse.

I find it very useful for alsorts of things.

Useage is :

result = diminish(variable to reduce, by how much each frame)

Maybe you could use this function to cushion the result you get before applying it.

Hope that helps.

IPete2.


t3K|Mac(Posted 2007) [#3]
i would use a simple collision sphere around your camera/character. if the sphere is big enough, your character will automatically climb stairs (even with bounce).


Shambler(Posted 2007) [#4]
Store the target Y distance off the ground that you want the camera to reach, e.g. PlayerHeight.

Then you just code something like
 If CameraY<PlayerHeight then CameraY=CameraY+(PlayerHeight-CameraY)/10)


This will smoothly move the camera into position.

If the camera does not move into position fast enough just reduce the 10 to a smaller value.


Naughty Alien(Posted 2007) [#5]
..collision sphere would be most elegant and simpliest way to achieve that without headache..


JA2(Posted 2007) [#6]
Thanks everyone for the suggstions.

I had a quick go with each method and found Shambler's code to do the job just nicely.

Not seen that Diminish() function before in the archives. Will be keeping that one handy ;o)


Boiled Sweets(Posted 2007) [#7]
I came up with a 'better' solution. My stair meshes have an invisible 'ramp'. The player collides with that so that there is a smooth 'glide' when going up/down stairs.


Beaker(Posted 2007) [#8]
That is the established way (using an invisible ramp), and it will make collisions faster (less polys). But, some prefer the (slightly?) more realistic effect you can get with real stairs.


t3K|Mac(Posted 2007) [#9]
its more realistic using real stairs. just sliding down a ramp looks pretty cheap (in my opinion). just walk down stairs, watch the horizon and you will see. but if you don't go for realism, using ramps is the way to go.


jfk EO-11110(Posted 2007) [#10]
When using shpehe to poly collision, ramps sometimes are the only solution. Eg. when the steps are too high. An additional alpha-zero quad that is aligned to the stairs, intersecting all steps slightly elevated may solve the problem. Usually added in a level editor.


Shambler(Posted 2007) [#11]
The way I used to code to cope with steps that are too high, or indeed any obstacle that your player should be able to climb over is this...

If the player is moving forwards then a line pick is cast downwards in front of the player, if the line pick hits geometry that is higher than the player then the player is raised slowy as if climbing up the obstable.

Of course if the object in front of the player is too high then they won't allowed to climb it.

I found this method makes the interaction with the world more satisfying.

Many games stop the player from climbing up over obstacles that they could climb in real life and I prefer to allow this behaviour in game.