Get all tilemap cells between two vector2 in godot 2D

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

Hi,

I am wondering how I can return all cells that are in my tilemap that are on the trajectory of two vectors in 2D space. I am using the distance_to function to get the distance between two vectors but what I am missing is how to receive all cells in between this way. Is it possible to retrieve those cells somehow through a function or any other way?

Thanks in advance!

:bust_in_silhouette: Reply From: Aeris130

Linedrawing algorithms can be used to compute all points that must be traversed on a grid in order to move from point A to point B.

https://www.redblobgames.com/grids/line-drawing.html

Hi! Thanks this helped me greatly! I got it working from my side!

BennieBe | 2022-10-04 11:38