title: How to slow down a sine wave?
body: <p>I want to program a <em>bouncing</em> ball. The actual bounce shouldn't follow real physic laws but rather build an absolute sine wave. Like in this image</p>
  
  <p><a href="https://i.stack.imgur.com/PqwoR.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PqwoR.jpg" alt="enter image description here"></a></p>
  
  <p>That is pretty easy so far. See the attached code.</p>
  
  <p>However I want to slow down the movement of my ball as soon as I press a button.</p>
  
  <p>I'll reduce the movement speed which will slow down the transformation on the x axis. But the ball is still bouncing pretty fast up and down, because neither frequency nor magnitude of the sine wave has changed. But when I change one or both, this will end in a weird behavior.</p>
  
  <p>Imagine the ball is on the downmove at 20% of the distance from top to bottom. When I now change any sine parameters the ball will instantly move on the y axis which looks really weird and not smooth.</p>
  
  <p>So my actual question is: <strong>How can I slow down an absolute sine wave (x/y axis translation) without choppy movement?</strong></p>
  
  <pre><code>float _movementSpeed = 10.0f;
  float _sineFrequency = 5.0f;
  float _sineMagnitude = 2.5f;
  
  Vector3 _axis;
  Vector3 _direction;
  Vector3 _position;
  
  void Awake()
  {
      _position = transform.position;
      _axis = transform.up;
      _direction = transform.right;
  }
  
  void Update()
  {
      _position += _direction * Time.deltaTime * _movementSpeed;
      // Time.time is the time since the start of the game
      transform.position = _position + _axis * Mathf.Abs(Mathf.Sin(Time.time * _sineFrequency)) * _sineMagnitude;
  }
  </code></pre>