All of the assets required can be downloaded here.
The sprites are in the Traps --> PlatformsÂ
Add the Platforms folder to the FileSystem
Create any level you like.
You may copy my level layout.
We will spawn Strawberries dynamicallyÂ
Also, we will create scenes for a Horizontal platform and Vertical Platform
How to make the chain / rail paths
The chain is just a TextureRect node
Which uses the Chain.png image as the texture
Set the Stretch mode to Tile
Now you can stretch the image
Rotate it 90 degrees for vertical rails
Select the RailLevel node
Set the number of strawberries you plan
add a new RectangleShape2D
Repeat this for the BottomMarker
Place the Areas and their children in the group
Position these markers in the level
Create a new scene with AnimatableBody2D as the root
This is so the player will move with the platform when on it
Rename it to HorizontalRail
Choose new RectangleShape 2D
Add a new Sprite Frames resource
Click on the SpriteFrames resource
Rename the default animation to "off"
Use the Brown Off.png as the only frame
Choose the Brown On.png file
Set Horizontal frames to 8
Set Target Position Y to -20
In the Collide With section
Allow the ray to collide with Areas
Set the Collision Mask to look for objects
Add an Area2D node as a child of VerticalRail
Add a CollisionShape2D node as a child of Area2D
Add a New RectangleShape2D
Extend the Area2D collision shape above the platform
The Vertical Rail will work as a lift
The player will press a button
Add a Label node as a child of VerticalRail
Set the text property of the label
Position the label above the platform
Attach a script to the VerticalRail node
Get a reference to the AnimatedSprite2D so that
we can play the off and on animations
Get a reference to the RayCast2D so we can stop at the top and the bottom
Get a reference to the label so that we can toggle visiblity
flag if the platform is moving
flag if the player is on the platform
The platform can only move
and the player presses "E"
Connect the body entered signal
Set up and interact action in the Input Map
Click on Project --> Project Settings --> Input Map
Add a New Action called interact
Map a key to it such as E
In the body entered function
Check if the body is the player
Connect the body exited signal
of the Area2D so that we know
when the player has left the lift
Code the body exited function
check if the body is the player
we should continuously check
if the player is on the lift
if the lift is not moving
and if the player has pressed the interact key
Move the lift in the physics process function
continuously update the y position of the lift
if the ray cast collides with a marker
invert the target position
reverse the direction of the lift