BulletSim: add 'AvatarAlwaysRunFactor' parameter and use in setTargetVelocity
to implement the 'always run' feature.0.7.5-pf-bulletsim
parent
70e0a86601
commit
7266eeca6e
|
@ -464,15 +464,15 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
{
|
{
|
||||||
DetailLog("{0},BSCharacter.setTargetVelocity,call,vel={1}", LocalID, value);
|
DetailLog("{0},BSCharacter.setTargetVelocity,call,vel={1}", LocalID, value);
|
||||||
OMV.Vector3 targetVel = value;
|
OMV.Vector3 targetVel = value;
|
||||||
|
if (_setAlwaysRun)
|
||||||
|
targetVel *= BSParam.AvatarAlwaysRunFactor;
|
||||||
|
|
||||||
PhysicsScene.TaintedObject("BSCharacter.setTargetVelocity", delegate()
|
PhysicsScene.TaintedObject("BSCharacter.setTargetVelocity", delegate()
|
||||||
{
|
{
|
||||||
_velocityMotor.Reset();
|
_velocityMotor.Reset();
|
||||||
_velocityMotor.SetTarget(targetVel);
|
_velocityMotor.SetTarget(targetVel);
|
||||||
_velocityMotor.SetCurrent(_velocity);
|
_velocityMotor.SetCurrent(_velocity);
|
||||||
_velocityMotor.Enabled = true;
|
_velocityMotor.Enabled = true;
|
||||||
|
|
||||||
// Make sure a property update happens next step so the motor gets incorporated.
|
|
||||||
BulletSimAPI.PushUpdate2(PhysBody.ptr);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,7 @@ public static class BSParam
|
||||||
// Avatar parameters
|
// Avatar parameters
|
||||||
public static float AvatarFriction { get; private set; }
|
public static float AvatarFriction { get; private set; }
|
||||||
public static float AvatarStandingFriction { get; private set; }
|
public static float AvatarStandingFriction { get; private set; }
|
||||||
|
public static float AvatarAlwaysRunFactor { get; private set; }
|
||||||
public static float AvatarDensity { get; private set; }
|
public static float AvatarDensity { get; private set; }
|
||||||
public static float AvatarRestitution { get; private set; }
|
public static float AvatarRestitution { get; private set; }
|
||||||
public static float AvatarCapsuleWidth { get; private set; }
|
public static float AvatarCapsuleWidth { get; private set; }
|
||||||
|
@ -367,6 +368,11 @@ public static class BSParam
|
||||||
(s,cf,p,v) => { AvatarStandingFriction = cf.GetFloat(p, v); },
|
(s,cf,p,v) => { AvatarStandingFriction = cf.GetFloat(p, v); },
|
||||||
(s) => { return AvatarStandingFriction; },
|
(s) => { return AvatarStandingFriction; },
|
||||||
(s,p,l,v) => { AvatarStandingFriction = v; } ),
|
(s,p,l,v) => { AvatarStandingFriction = v; } ),
|
||||||
|
new ParameterDefn("AvatarAlwaysRunFactor", "Speed multiplier if avatar is set to always run",
|
||||||
|
1.3f,
|
||||||
|
(s,cf,p,v) => { AvatarAlwaysRunFactor = cf.GetFloat(p, v); },
|
||||||
|
(s) => { return AvatarAlwaysRunFactor; },
|
||||||
|
(s,p,l,v) => { AvatarAlwaysRunFactor = v; } ),
|
||||||
new ParameterDefn("AvatarDensity", "Density of an avatar. Changed on avatar recreation.",
|
new ParameterDefn("AvatarDensity", "Density of an avatar. Changed on avatar recreation.",
|
||||||
3.5f,
|
3.5f,
|
||||||
(s,cf,p,v) => { AvatarDensity = cf.GetFloat(p, v); },
|
(s,cf,p,v) => { AvatarDensity = cf.GetFloat(p, v); },
|
||||||
|
|
Loading…
Reference in New Issue