public override void Simulate(ActorArgs _args) { ActorHeader.Actor Actor = _args.Actor; ActorHeader.GroundHit Ground = Actor.Ground; // Ground is currently last frame as we have not moved until ActorMove() of this simulation ActorHeader.GroundHit LastGround = Actor.LastGround; // LastGround is the frame prior to the last Vector3 _v = Actor._velocity; bool _applyfriction = _v.sqrMagnitude > 0F; if (!_applyfriction) { return; } LastGroundSnapshot = (Ground.snapped && !LastGround.snapped) ? GlobalTime.T : LastGroundSnapshot; float _vm = _v.magnitude; // Determine whether to apply ground friction or air friction bool _applygroundfriction = (Actor.SnapEnabled && Ground.stable) && (GlobalTime.T - LastGroundSnapshot) > GroundFrictionLeeway; if (_applygroundfriction) { BehaviourHeader.ApplyFriction(ref _v, _vm, GroundFriction, GlobalTime.FDT); } else { BehaviourHeader.ApplyFriction(ref _v, _vm, AirFriction, GlobalTime.FDT); } Actor.SetVelocity(_v); }
public override void Simulate(ActorArgs _args) { ActorHeader.Actor Actor = _args.Actor; Vector3 Velocity = Actor._velocity; Vector3 Wish = _args.ViewWishDir; //BehaviourHeader.DetermineWishVelocity(ref Velocity, Wish, MaximumFlySpeed, FlyAcceleration * GlobalTime.FDT); BehaviourHeader.ApplyAcceleration(ref Velocity, Wish, MaximumFlySpeed, FlyAcceleration); BehaviourHeader.ApplyFriction(ref Velocity, Velocity.magnitude, FlyAirFriction, GlobalTime.FDT); Actor.SetVelocity(Velocity); }