Moving an Object after Picking up another Object

Hi,
im new to programming and im a bit stuck here
im trying to move an object after i pick up some other object
i can mannage to pick up an object but now i dont know how can i let my programme know i picked it up and move the other object

i had try this but it seems not working
it maybe im using some wrong method, so if there is some better method or some example
please let me know with lots of thanks

	void OnTriggerEnter(Collider other){
		if(other.gameObject.tag == "Player"){
			this.gameObject.SetActive(false);
		
		}

	}

	public void _moveObject(){
		//gameObject.Find("MoveAfterPick").transform.translate.position(1,1,0);
	}

Kinda hard to get what you’re getting at, but you want the object you have picked up to move when the the player moves, correct?

The easiest way is to set the player as the parent of the picked up object. Child objects moves whenever their parent moves. Simply do:

pickedUpObject.transform.parent = playerObject.transform;

If you’re picking up on trigger enter, as in your example:

void OnTriggerEnter(Collider other){
    if(other.gameObject.tag == "Player"){
        transform.parent = other.transform;
    }
}

You could use the function MoveTowards, where you’d insert the current and target position in the parameter, and with that you could make the object move from point A to point B. Here’s the documentation on that function:

It should be something like this:

void OnTriggerEnter(Collider other){
        if(other.gameObject.tag == "Player"){
            this.gameObject.SetActive(false);
            _moveObject();
        }
 
    }
 
    public void _moveObject(){
        GameObject objectToMove = GameObject.Find("MoveAfterPick");

         while (objectToMove.transform.position != endPos)
        {
           MoveTowards(currPos, endPos, step);
        }
    }

Something along those lines, haven’t really tested it.