default pathfinding cannot bypass cliff

Place to get help with not working mods / modding interface.
Post Reply
kevinma
Inserter
Inserter
Posts: 33
Joined: Tue Jan 08, 2019 4:07 pm
Contact:

default pathfinding cannot bypass cliff

Post 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 702 times
截屏2020-01-31上午10.34.33.png
截屏2020-01-31上午10.34.33.png (4.47 MiB) Viewed 702 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 702 times

kevinma
Inserter
Inserter
Posts: 33
Joined: Tue Jan 08, 2019 4:07 pm
Contact:

Re: default pathfinding cannot bypass cliff

Post 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 657 times

Post Reply

Return to “Modding help”