In this tutorial you learn how to set up platforms. Platforms can be used for instance for elevators. Open up the Moving platforms.map from the tutorial project.
Setting Up WaypointsThe platforms you see in the scene are simple CSG boxes. They have the following physics settings: physics type is set to "Rigidbody", Mass is set to '2' and Collision type to "Prop".
Attached on these platform is the script platform.lua. You can set the speed and target platform. The speeds indicates how fast a platform moves towards its target. The target is the position/location the platform should move to first.
The colored icon (as shown in the image below) represents a pivot. Pivots have no physics, don't render anything and are basically just position entities. Pivots can be created from the Objects tab under Miscellaneous.
Select a waypoint pivot. You can see the platformwaypoint .lua. Here you can drag a new target on top of it. If you click on the ‘GoTo’ button, the scene will focus on the object in the scene. Select the platform. You can see that we can set a target here as well.
Creating a Moving PlatformWe create 3 pivots in the scene. We call them W1, W2 and W3. Select all 3 pivots by holding the CTRL key and selecting them in either the viewports or in the scene tab.
We attach the platformwaypoint script to it. Select the first Waypoint. Drag Waypoint 2 in to the target property of Waypoint 1. Do the same thing for the other waypoints.
Create a new CSG box at the first pivot and attach the platform script. Set as a target, the second waypoint. Don’t forget to set the mass to ‘2’ and collision type to prop.