Page 1 of 1

default pathfinding cannot bypass cliff

Posted: Fri Jan 31, 2020 2:47 am
by kevinma
I try to control my man by scripts. I invoke surface.request_path and find a path. But It can't bypass the cliff and the forest.
Follow is the piece of my code:

Code: Select all

self.path_id = entity.surface.request_path({
        bounding_box = entity.bounding_box,
        collision_mask = {"player-layer"},
        start = entity.position,
        goal = self.position,
        force = entity.force,
 })
 
Should I change the collision_mask parameter?
surface.request_path may fail if i use it frequently. Once it failed, it always fails in future for a time.
截屏2020-01-31上午10.23.37.png
截屏2020-01-31上午10.23.37.png (2.9 MiB) Viewed 906 times
截屏2020-01-31上午10.34.33.png
截屏2020-01-31上午10.34.33.png (4.47 MiB) Viewed 906 times
In some case , the pathfinding algorithm cannot generate a straight way when there is no obstruction. By the way, is there any mod implement a custom pathfinding algorithm?
WX20200131-104437@2x.png
WX20200131-104437@2x.png (2.05 MiB) Viewed 906 times

Re: default pathfinding cannot bypass cliff

Posted: Sat Feb 01, 2020 7:48 am
by kevinma
I figure out the problem. I should pass the entity.prototype.collision_box instead of entity.bounding_box.

But another problem still exists, the api failed frequently.

To solve the problem, i implements a custom pathfinding algorithm . It works but slow :(
WX20200201-181905@2x.jpg
WX20200201-181905@2x.jpg (545.38 KiB) Viewed 861 times