To create a moving platform, you will need to provide the position of the origin and destination which you can provide with empty game objects. It might be easier as well to place an Icon to see where these destinations are:
For the Moving_Platform object itself, we will need to add a script to move the platform from one position to another. We can use Vector3.MoveTowards, and provide the positions and the speed of movement. We will also add a control variable to determine if it’s moving from A to B or B to A. On my end, this variable is called, _switching.
As you can see below, the Moving_Platform is indeed moving to and from the positions specified and visualized with the green and blue circles:
There’s only one bug though that the Player is not stuck on the Moving_Platform so if you do not move your controller. The player will fall. This will be addressed in the next article.