/// <summary> /// /// </summary> private void CalculateMovementVelocity() { switch (_surfer.MoveType) { case MoveType.Walk: if (_surfer.GroundObject == null) { // apply movement from input _surfer.MoveData.Velocity += AirInputMovement(); // let the magic happen SurfPhysics.Reflect(ref _surfer.MoveData.Velocity, _surfer.Collider, _surfer.MoveData.Origin, _deltaTime); } else { // apply movement from input _surfer.MoveData.Velocity += GroundInputMovement(); // jump/friction if (_surfer.MoveData.Buttons.HasFlag((int)InputButtons.Jump)) { Jump(); } else { var friction = _surfer.MoveData.SurfaceFriction * _config.Friction; var stopSpeed = _config.StopSpeed; SurfPhysics.Friction(ref _surfer.MoveData.Velocity, stopSpeed, friction, _deltaTime); } } break; } }
private void CalculateNoclipVelocity() { AngleVectors(_surfer.MoveData.ViewAngles, out Vector3 forward, out Vector3 right, out Vector3 up); var wishVel = Vector3.zero; for (int i = 0; i < 3; i++) { wishVel[i] = forward[i] * _surfer.MoveData.ForwardMove + right[i] * _surfer.MoveData.SideMove; } var wishDir = wishVel.normalized; _surfer.MoveData.Velocity += wishDir * _config.NoclipSpeed; SurfPhysics.Friction(ref _surfer.MoveData.Velocity, _config.StopSpeed, _config.NoclipFriction, _deltaTime); }
private void CalculateWalkVelocity(float modifier = 1.0f) { if (_surfer.GroundObject == null) { _surfer.MoveData.Velocity += AirInputMovement() * modifier; if (_surfer.MoveData.Buttons.HasFlag(InputActions.Brake)) { var vely = _surfer.MoveData.Velocity.y; SurfPhysics.Friction(ref _surfer.MoveData.Velocity, 0f, _config.BrakeSpeed, _deltaTime); _surfer.MoveData.Velocity.y = vely; } } else { _surfer.MoveData.Velocity += GroundInputMovement() * modifier; var friction = _surfer.MoveData.SurfaceFriction * _config.Friction; var stopSpeed = _config.StopSpeed; SurfPhysics.Friction(ref _surfer.MoveData.Velocity, stopSpeed, friction, _deltaTime); } }