//public float NetRight //{ // get { return Right - Left; } //} // //public float NetDown //{ // get { return Down - Up; } //} public void Update(float frameTime, MovementInput input) { Right = input.LookRight / 2; Down = input.LookDown / 2; //Left += input.LookRight * frameTime; //Right += (input.Rightward ? Acceleration : Deceleration) * frameTime; //Up += input.LookDown * frameTime; //Down += (input.LookDown ? Acceleration : Deceleration) * frameTime; // //var maxVelocity = frameTime * 0.15f; // //Left = Left.Clamp(0, maxVelocity); //Right = Right.Clamp(0, maxVelocity); //Up = Up.Clamp(0, maxVelocity); //Down = Down.Clamp(0, maxVelocity); }
public void Update(float frameTime, MovementInput input) { Forward += (input.Forward ? Acceleration : Deceleration) * frameTime; Backward += (input.Backward ? Acceleration : Deceleration) * frameTime; Leftward += (input.Leftward ? Acceleration : Deceleration) * frameTime; Rightward += (input.Rightward ? Acceleration : Deceleration) * frameTime; Upward += (input.Upward ? Acceleration : Deceleration) * frameTime; Downward += (input.Downward ? Acceleration : Deceleration) * frameTime; var maxVelocity = Constants.MaxVelocity; if (input.Sprint) { maxVelocity *= 3; } Forward = Forward.Clamp(0.0f, maxVelocity); Backward = Backward.Clamp(0.0f, maxVelocity); Leftward = Leftward.Clamp(0.0f, maxVelocity); Rightward = Rightward.Clamp(0.0f, maxVelocity); Upward = Upward.Clamp(0.0f, maxVelocity); Downward = Downward.Clamp(0.0f, maxVelocity); }