public void UpdateVelocity(Matrix MatrixTransform, float delta) { /*Anti Acc Force*/ Drag = DragCoff * Speed; //Unit: N Vector3 directedThrust = Vector3.TransformNormal(new Vector3(0, 0, 1), MatrixTransform); /*(0,0,1) is the original ship direction*/ /*Compute Acc and De-Acc*/ Acc = UserThrust / CurrentWeight; Deacc = Drag / CurrentWeight; if (Acc > 0) { /*Compute Velocity and Speed*/ CurrentVelocity += directedThrust * Acc * delta; SpeedDir = CurrentVelocity; if (Speed != 0 && SpeedDir != Vector3.Zero) { SpeedDir.Normalize(); } CurrentVelocity -= SpeedDir * Deacc * delta; //M/S^2 Speed = CurrentVelocity.Length(); //M/S } else { SpeedDir = CurrentVelocity; if (Speed != 0 && SpeedDir != Vector3.Zero) { SpeedDir.Normalize(); } CurrentVelocity -= SpeedDir * (Deacc - Acc) * delta; //M/S^2 Speed = CurrentVelocity.Length(); //M/S } }
public override void Update() { if (IsDead) { return; } if (CurrentVelocity.Length() > 1) { CurrentVelocity.Normalize(); } // Update speed Character.SetVelocity(CurrentVelocity * MaximumSpeed); ApplyHeadRotation(HeadRotation); ApplyBodyRotation(BodyRotation); // Body hover const float amp = 0.05f; const float freq = 0.5f; Model.Entity.Transform.Position.Y = initialHeight + amp * (float) Math.Sin((initialShift + Game.UpdateTime.Total.TotalSeconds) * freq * 2 * Math.PI); }