[Unity]Use localPosition to create a conveyor belt-like


Hello.
Today I would like to make a simple conveyor belt using localPosition.

As a quick start, we will place a rectangular cube that will serve as the foundation of the conveyor belt. The black cube in the image below is the base of the conveyor belt.
Then, place child objects on the base. *The small white cube in the image below.

Add a script to the child object prepared above. *BeltConveyour script

After adding the script, duplicate the child objects at equal intervals and place them. (In this case, the script is a sample, so it is placed appropriately.

The BeltConveyour script will gradually move the object to the left, and when it reaches the left edge of the parent object, move it to the right edge, and then gradually move it to the left again.

Assign its own localPosition to the pos variable, and when the x-axis value is changed, set the value of the pos variable back to localPosition.
When it reaches -0.46f (leftmost), we move it to 0.46f (rightmost), but I think there is a more efficient way. I think there is a more efficient method. I’m sure there is a more efficient method;

When the game is executed, the conveyor belt starts moving and the cubes falling from the pre-fabricated falling device made separately are carried to the left.

– Sample -.