How do I make one object go in the same way and with the same speed as the other object?

Hi. I’m ‘throwing’ one object using the SpringJoint2D. How can I make other object go with the same speed as of this one? (and in the same direction)

there are multiple ways to do this, depending on what components you use and what behaviour you want

  1. if you are using rigidbodies:

object2.GetComponent().velocity = object1.GetComponent().velocity;

  1. storing the difference, then updating it every frame:

Start:

Vector3 difference =
obj2.transform.position -
obj1.trandform.position;

update:

obj2.trandform.position =
obj1.transform.position + difference;

  1. make it a child of the thrown object?