hello there !
Working on the "power" of one of my towers for my tower defense game.
One of them would be to teleport back a unit along his path.
The path isn't pre traced as the towers you place make the maze.
So im using getsimplepath.

Do see any way to "track back" a certain amount of pixel ?
Im thinking of doing a getsimplepath from mob.position to startspawn ---> but how do i define a point X pixel from starting point ? is that feasible with getsimple_path ?

in Engine

`get_simple_path` returns an array of points, these can be added to a curve on a path node using a for loop and add_point. A child PathFollow node can then work with pixel units along that path.

by (3,257 points)

But wouldn't that make my mob walk to the point rather than reposition him there ?

Also, since the points are automatically generated.
It would be a far point. I'd like to be precise on how many PX back i can Teleport the unit.

The offset of PathFollow2D is basically the exact distance along the path in pixel units, the only way your mob would walk there is if you are using lerp to change a separate value for the offset.

that's awesome ! Thx i didn't know.
I'm going to look into how to formulate that now.

Hey Magso !
do you have any example of i could learn from ?

these can be added to a curve on a path node using a for loop and add_point.

Here's a simple example of using `get_simple_path` with the path and pathfollow nodes.

``````func _ready():
for i in path.size():

func _process(delta):
\$Path/PathFollow.offset += delta*10
``````

Edit I forgot you're working in 2D luckily it's not too different.

``````func _ready():
for i in path.size():

func _process(delta):
\$Path2D/PathFollow2D.offset += delta*10
``````

sweet ! thanks Magso.
so, if I got this right.

set my path backward (done)
which returns an array of points.
which i can append a new point to a specific pixel distance.

Im reading the doc that you link but I can't seems to find how to "mesure" the distance in px from on that path.
Adding a point seems fairly easy, i will need to figure out how to get the position.x/.x from it to then "teleport" my unit on it.

EDIT :
here is a quick graph to make sure we're on the same page :D

just realized that the link was for 3d. i read the 2d and I found this :

Vector2 interpolate_baked ( float offset, bool cubic=false ) const
Returns a point within the curve at position offset, where offset is measured as a pixel distance along the curve.

To do that, it finds the two cached points where the offset lies between, then interpolates the values