Setting A Object As A Temporary Child And Releasing It In Unity

Maurice Davis
3 min readJan 27, 2024

In this article i would like to use the forks of the forklift to trigger the stack of pallets to become the child of the forks and then release pallet.

Preparing The Colliders:

First thing we want to do is put two colliders on the forks, these will not be the triggers.

Next, we want to add a new collider to the bottom of the stack of pallets and set it to the trigger.

MakeChild Script:

Now let’s create a script for the pallets and call it “MakeChild” and create two new variables. the first one will be a transform, which will track our fork’s position. The next will be a game object which will tell the pallets who is it’s temporary parent last we just need a bool to turn this trigger off and on.

We want to just create three new methods, one to set the parent and the other to release from the parent and last to set the bool to false.

--

--