title: Taking average of multiple Vector3's
body: <p>So I'm working with a depth-camera that works like kinect. (it's not kinect). and with Nuitrack behind it for skeleton tracking. However, The position it returns for the player is shaky. When standing perfectly still it returns numbers that can go up or down by up to like 10. </p>
  
  <p>Example: User is standing as still as he can and the data returns position 100 the first frame, and the next frame it's 102, then it's 97 then its 100 again, then it's 106 etc. It returns these positions in the update and we use it to move a image with it. (so the user controls the image) But as you might expect this image is moving very shaky because of the inconsistent data. According to Nuitrack this is right, and the user itself needs to find a solution for this.
  <a href="https://i.stack.imgur.com/uMFam.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uMFam.png" alt="enter image description here"></a> </p>
  
  <p>I tried lerping from one position to another, but this makes it feel less interactive, because once i'm on the point where the lerp is actually smooth, it has a huge delay. I also tried only using the new position data if it differs lets say 4 pixels from the previous position nuitrack gave me, this works a bit better but results in jumping of the image, even if I lerp it as well. Using this function:</p>
  
  <pre><code>foreach (User user in frame.Users)
          {
              if (Vector3.Distance(_lastPos, user.Proj.ToVector3()) &gt;4f)
              {
                  Vector3 final = ((_lastPos + user.Proj.ToVector3()) /2);
                  userData.Add(new UserData(user.ID, user.Real.ToVector3(), final));
                  _lastPos = user.Proj.ToVector3();
              }
              else
              {
                  userData.Add(new UserData(user.ID, user.Real.ToVector3(), _lastPos));
              }
  </code></pre>
  
  <p>And the lerp function:</p>
  
  <pre><code>float _userX = user.ProjPosition.x * (_cameraPos.x *2)- _cameraPos.x;
              Vector3 _newPos = new Vector3(_userX, _basketPos.y, _basketPos.z);
              _basketPrefab.transform.position = Vector3.Lerp(_basketPrefab.transform.position, _newPos, Time.deltaTime * 30f);
  </code></pre>
  
  <p>EDIT: Anyone else?</p>