How best to implement attaching an object to a transport?

when the transport runs to the trigger object, when you press a key, the object will be assigned to parental
Here is a photo

It would be desirable that when you press a key, the project hit is attached in this way

The question is how to implement this idea!
With the help of animation,?

bool canAttach;
GameObject attachable;
public Vector3 attachedPosition;

void Update()
{
  if(Input.GetKey(KeyCode.Space))
  {
    if(canAttach)
    {
      attachable.transform.parent = gameObject.transform;
      attachable.transform.localPosition = attachedPosition;
    }
  }
}

OnTriggerEnter(Collider other)
{
  if(other.tag == "attachable")
  {
    canAttach=true;
    attachable = other.gameObject;
  }
}

OnTriggerExit(Collider other)
{
  if(other.tag == "attachable")
  {
    canAttach=false;
    attachable = null;
  }
}

this should work now