BulletSim: tweeks to make avatar jump work better.

user_profiles
Robert Adams 2013-02-25 21:58:00 -08:00
parent a356978c79
commit 2b53f08386
1 changed files with 6 additions and 4 deletions

View File

@ -204,7 +204,7 @@ public sealed class BSCharacter : BSPhysObject
// move. Thus, the velocity cannot be forced to zero. The problem is that small velocity // move. Thus, the velocity cannot be forced to zero. The problem is that small velocity
// errors can creap in and the avatar will slowly float off in some direction. // errors can creap in and the avatar will slowly float off in some direction.
// So, the problem is that, when an avatar is standing, we cannot tell creaping error // So, the problem is that, when an avatar is standing, we cannot tell creaping error
// from real pushing.OMV.Vector3.Zero; // from real pushing.
// The code below keeps setting the velocity to zero hoping the world will keep pushing. // The code below keeps setting the velocity to zero hoping the world will keep pushing.
_velocityMotor.Step(timeStep); _velocityMotor.Step(timeStep);
@ -254,8 +254,10 @@ public sealed class BSCharacter : BSPhysObject
} }
// If falling, we keep the world's downward vector no matter what the other axis specify. // If falling, we keep the world's downward vector no matter what the other axis specify.
// The check for _velocity.Z < 0 makes jumping work (temporary upward force).
if (!Flying && !IsColliding) if (!Flying && !IsColliding)
{ {
if (_velocity.Z < 0)
stepVelocity.Z = _velocity.Z; stepVelocity.Z = _velocity.Z;
// DetailLog("{0},BSCharacter.MoveMotor,taint,overrideStepZWithWorldZ,stepVel={1}", LocalID, stepVelocity); // DetailLog("{0},BSCharacter.MoveMotor,taint,overrideStepZWithWorldZ,stepVel={1}", LocalID, stepVelocity);
} }
@ -572,7 +574,7 @@ public sealed class BSCharacter : BSPhysObject
m_targetVelocity = value; m_targetVelocity = value;
OMV.Vector3 targetVel = value; OMV.Vector3 targetVel = value;
if (_setAlwaysRun) if (_setAlwaysRun)
targetVel *= BSParam.AvatarAlwaysRunFactor; targetVel *= new OMV.Vector3(BSParam.AvatarAlwaysRunFactor, BSParam.AvatarAlwaysRunFactor, 0f);
PhysicsScene.TaintedObject("BSCharacter.setTargetVelocity", delegate() PhysicsScene.TaintedObject("BSCharacter.setTargetVelocity", delegate()
{ {