Godot Version
4.3
Question
I’m trying to create an obstacle in my 2D platformer that acts as a conveyor belt but I’m kind of stumped and google was no help.
The idea is to use an Area2D to determine when the player is standing on the belt, and when they are, do the following:
- Automatically move the player in the direction of the belt while they’re standing still
- Slow their movement speed when they are moving in the opposite direction of the belt’s movement
So, if they belt is moving to the left and the player is standing on the belt, the player moves to the left, and if the player moves to the right while the belt is moving left, the player moves much more slowly.
I’m using this tutorial:
Making a Better 2D Movement Controller (Part 1)
so my player movement and input are in separate components. My movement component looks like this:
When I alter the speed variable directly, it makes my character move at a slower speed, as expected. But when I try to change the speed variable from inside my conveyor script like this:
so that it is reduced to fifty while standing on the belt, it doesn’t work. How else would I be able to slow the player while they’re standing inside the Area2D? And how would I go about automatically moving them in the direction of the belt as long as they’re not giving any input?
Apologies for the lengthy post, I’m just trying to be as thorough as I possibly can in explaining how my game is structured and what I’m trying to accomplish.