Following a Line

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

What is a simple way to get an Area2D to follow the course of a Line2D?

:bust_in_silhouette: Reply From: MysteryGM

What do you mean by follow a line?
If you mean it should move like a vehicle on a road, that is what paths are for. The Godot step by steps touches on this.

If you want to make a complex shape like a Z then you need to use more than one collision box.
The reason is that the 3 Area2D objects will resolve collisions faster than a polygon shaped as a Z. In games lots of collision shapes are mixed to create a rough form; to save on math calculations.

If you want a very long collision box then splitting it into smaller ones is also better. A path that spawns the colliders would work for this.

Can you elaborate on what you are trying.

I want to draw a line with a Line2D, and have a node follow the path of that Line2D

ThreeSpark | 2018-11-06 00:38

:bust_in_silhouette: Reply From: gtkampos

You should use a path2d and pathfollow2d nodes: