Navigation2D get*simple*path() returns navigation nodes and I can lerp from one node to another, but how can I **lerp or tween whole path**. I.e. RTS style space ship should build up speed at start and slow down at the end of the path.

0 votes

Best answer

You can use the PathFollow node by adding the returned path to the curve2D on a Path2D node.

```
for i in navigation_path.size():
Path2D.curve.add_point(navigation_path[i])
#and use this in _process
PathFollow2D.unit_offset = lerp(PathFollow2D.unit_offset, 1, delta)
```

Without a PathFollow2D you can't use a single lerp or tween but you can lerp through the array using lerps like this

```
lerp_num = lerp(lerp_num, navigation_path.size()-1, delta)
sprite.position = lerp(navigation_path[int(lerp_num/(int(lerp_num)+0.01))], navigation_path[int(lerp_num/(int(lerp_num)+1))], lerp_num/(int(lerp_num)+0.01))
```

The +0.01 is so it's not dividing by zero.

- All categories
- Engine 16,642
- Projects 2,044
- Gossip 284