How do I make an obstacle bounce around the screen?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By AshTheKindra

So this is a question that does sound a bit ridiculously simple, but I also I am really new to Godot and I have been learning godot for only few months so that’s why I am asking. So I’m making a 2D platformer and I want to have an obstacle that bounces around. I have looked around for tutorials on how to make an object bounce around, but I haven’t found a tutorial where I can make the object bounce independently without player input. I just want my obstacle to just bounce around the stage. Any help is a appreciated.

:bust_in_silhouette: Reply From: IceExplosive

You can have invisible walls (collision area without a sprite) around whole level to make sure it doesn’t get out it.

If your level is bigger than screen and you want to bounce around visible area, you can add that invisible wall into the Camera2D scene… so it moves with your camera together and will always be just behind the edge.

Ok, but I want it to start at a certain position outside of the players view and bounce around that specific area of the level. I don’t want it to necessarily bounce around the the entire level or bounce around only the players camera.

AshTheKindra | 2021-07-11 20:58

Then it’s all the same, if it’s specific area, just place an Area2D there and give it proper collision layer.

IceExplosive | 2021-07-12 05:41