title: Find and add the velocity of a Rigidbody that's directly below another? (Unity + C#)
body: <p>I have an issue that I've not been able to solve for a few days now and without it working I can't move on with my project, so your help would be greatly appreciated!</p>
  
  <p>What I'm trying to do is 'find' the velocity of an object that is directly below my 2D sprite (that also contains a Rigidbody and 2D box collider) and then add that velocity (in the same direction) to the object that is 'looking' for it.</p>
  
  <p>I feel like ray-casting might be part of the answer but I'm not sure how to use that, especially in this context.</p>
  
  <p>The idea behind this is I have a platform that can carry objects stacked on top of each other, so you move the mouse, it manipulates the platforms velocity, but this causes the objects on-top to fly backwards, no mater how high the friction is.</p>
  
  <p>Here is the platform code:</p>
  
  <pre><code>void Update()
  {
  
      float distance_to_screen = Camera.main.WorldToScreenPoint(gameObject.transform.position).z;
  
      Vector3 pos_move = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, distance_to_screen));
  
      mouseDelta = pos_move - lastMousePosition;
  
      acceleration = mouseDelta.x * 0.4f;
      platformVelocity += acceleration;
      platform.velocity = new Vector2(platformVelocity, 0) * speed;
  
      lastMousePosition = pos_move;
  
  }
  </code></pre>
  
  <p>Thank you for taking the time to read this, I would very much appreciate any help you can give!</p>