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); }
public override void Simulate(ActorArgs _args) { ActorHeader.Actor Actor = _args.Actor; ActorHeader.GroundHit Ground = Actor.Ground; ActorHeader.GroundHit LastGround = Actor.LastGround; Vector3 Velocity = Actor._velocity; Vector3 Wish = _args.ViewWishDir; bool Grounded = Actor.SnapEnabled && Ground.stable; if (Grounded && !LastGround.stable) // Landing { VectorHeader.ClipVector(ref Velocity, Ground.normal); } // Orient Wish Velocity to grounding plane if (Grounded && OrientVelocityToGroundPlane) { VectorHeader.CrossProjection(ref Wish, new Vector3(0, 1, 0), Ground.normal); } else { // Clip Wish Velocity along upward plane if we're not orienting/stable as we may be able to fight gravity if not done VectorHeader.ClipVector(ref Wish, new Vector3(0, 1, 0)); Wish.Normalize(); } //if (Grounded) // Subtract max speed based on stability // BehaviourHeader.DetermineWishVelocity(ref Velocity, Wish, MaximumGroundMoveSpeed, GroundAcceleration * GlobalTime.FDT); //else // BehaviourHeader.DetermineWishVelocity(ref Velocity, Wish, MaximumAirMoveSpeed, AirAcceleration * GlobalTime.FDT); if (Grounded) { BehaviourHeader.ApplyAcceleration(ref Velocity, Wish, MaximumGroundMoveSpeed, GroundAcceleration); } else { BehaviourHeader.ApplyAcceleration(ref Velocity, Wish, MaximumAirMoveSpeed, AirAcceleration); } Actor.SetVelocity(Velocity); return; }