Player Step bug - player steps up vertical surfaces
by Drew Parker · in Torque Game Engine · 10/11/2005 (1:00 pm) · 1 replies
I noticed that the player will walk up vertical surfaces that are slightly angled in some situations. I have seen the player walk up trees and fences, either a DTS or DIF object. The easy solution is to make sure all your walls and vertical polygons only form 90 degree angles with the floor. But this cannot be guaranteed all the time, like with the base of some trees.
The player code checks to see if the surface it bumps is greater then 80 degrees (sVerticalStepDot), and if the player maxstepheight + current position can step past the highest vertex in the collision list (collisionList.maxHeight). But the problem is it does not check if the player is standing on anything, nor if there is anything to step to. So this causes the player to run up certain surfaces he should not. For instance, with the tree example, if the base of your tree has one polygon that is shorter then the maxStepHeight, and is > 80 degrees, the player may try to step up it, then run up your whole tree.
To get around this, in game/player.cc, in Player::updatePos(), find this:
And change it to this:
And write above it, put this:
That code block was taken directly from Player::updateMove(), and it basically just checks to see if the player is standing on something. This will (hopefully) fix the problem of the player scaling slightly angled trees and fences effortlessly, because it stops the player from repeadetely stepping up things.
However, if it will not stop the player from trying to take the first step (to nowhere). Perhaps there is way to check first if there is a surface for the player to step to?
The player code checks to see if the surface it bumps is greater then 80 degrees (sVerticalStepDot), and if the player maxstepheight + current position can step past the highest vertex in the collision list (collisionList.maxHeight). But the problem is it does not check if the player is standing on anything, nor if there is anything to step to. So this causes the player to run up certain surfaces he should not. For instance, with the tree example, if the base of your tree has one polygon that is shorter then the maxStepHeight, and is > 80 degrees, the player may try to step up it, then run up your whole tree.
To get around this, in game/player.cc, in Player::updatePos(), find this:
// Try stepping if there is a vertical surface
if (collisionList.maxHeight < start.z + mDataBlock->maxStepHeight * scale.z) {And change it to this:
if (runSurface && (collisionList.maxHeight < start.z + mDataBlock->maxStepHeight * scale.z)) {And write above it, put this:
// Also check for run surface. --drew VectorF contactNormal; bool jumpSurface = false, runSurface = false; if (!isMounted()) findContact(&runSurface,&jumpSurface,&contactNormal);
That code block was taken directly from Player::updateMove(), and it basically just checks to see if the player is standing on something. This will (hopefully) fix the problem of the player scaling slightly angled trees and fences effortlessly, because it stops the player from repeadetely stepping up things.
However, if it will not stop the player from trying to take the first step (to nowhere). Perhaps there is way to check first if there is a surface for the player to step to?
Torque Owner Eric Hartman
To avoid the first step problem, Perhaps you can do the step and then do a findContact() and if you don't get anything, undo the step?