+2 votes

Hi,

Hi, I've been tinkering with moving platforms horizontally and vertically for a platform game. I'm struggling though, as I'm not sure what people typically do.

I wish to re-use the sprite and script within the game, so I considered that it should move freely, but only reverse direction when it reaches an invisible marker sprite that I add at one end and the other.

But that raised other questions, "How do you detect the collision to reverse?", "Should the moving platform be a KinamaticBody2D, or something else?", "Do I use layers to prevent the player from colliding with the invisible marker?", if so how?

There's so few examples of this online and none seem applicable, what would you guys suggest?

Thanks.

Please note, this is for a pixel platform game, so lerps etc probably wouldn't move so well.

in Engine by (72 points)

You can put an AnimationPlayer component on it, create a new animation.

THIS will enable you to see keys icons on everywhere for everything in settings. For example, you want to move the position A to B, so you will need a start point and and ending point. Click on the key icon near the position settings, and this will create a track for animation of the position with the key on starting point. Move the platform and then choose an ending point clicking in the track timeline, then click on the key icon button again. Voilá, you will have an animation.

Plus, you even don't need a line of code to animate this. You can go to AnimationPlayer settings and click on "A" (Autoplay on load) and also click on "Animation looping" button.

When you play this level will perform the move automatically.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.