Solarus-Games English Forum

Solarus => Development => Topic started by: Yruama on June 14, 2015, 07:03:23 PM

Title: Path finding movement
Post by: Yruama on June 14, 2015, 07:03:23 PM
Hello,

I want to use this : http://www.solarus-games.org/doc/latest/lua_api_path_finding_movement.html (http://www.solarus-games.org/doc/latest/lua_api_path_finding_movement.html) so i do this :

myInterrupt.on_activated = function()
game:start_dialog('myDialog')
local m = sol.movement.create('path_finding')
m:set_target(map:get_entity("hero"))
m:set_speed(64)
m:start(myNPC)
end


but myNPC have a random movement.

What i fail ?
Title: Re: Path finding movement
Post by: the bread on June 15, 2015, 05:13:09 PM
I don't see any mistakes in this code but as I have not so much experience, I might have overlooked something. However, I know that the path finding movement sometimes does strange things ;D Maybe you would be fine with the target movement?
Title: Re: Path finding movement
Post by: Christopho on June 15, 2015, 05:35:44 PM
The NPC will do a random movement if no path is found, or if it is too far from the hero.
Title: Re: Path finding movement
Post by: the bread on June 15, 2015, 06:27:27 PM
How far is too far?
Title: Re: Path finding movement
Post by: Christopho on June 15, 2015, 06:57:41 PM
If the manhattan distance is > 200 pixels.
Title: Re: Path finding movement
Post by: Yruama on June 15, 2015, 07:06:19 PM
The distance is between the NPC and the button : http://puu.sh/ipSKa/faa099e917.png

Its under 200 px :(
Title: Re: Path finding movement
Post by: the bread on June 15, 2015, 07:09:03 PM
That doesn't look as if there was a path...
Title: Re: Path finding movement
Post by: Yruama on June 15, 2015, 07:14:08 PM
when i speak with the NPC the bloc is set disabled
Title: Re: Path finding movement
Post by: Christopho on June 16, 2015, 10:24:04 AM
Is the NPC on the same layer as the hero?
Does it work if you try a movement of type "target" insted of "path_finding"?
Does it work if there is no block at all? (If yes, then there is a bug with disabled blocks.)
Title: Re: Path finding movement
Post by: Yruama on July 07, 2015, 05:32:04 PM
They are on the same layer.

Without block it dose not work

i will try with target but it's a labyrinth so i guss Path finding is better ...
Title: Re: Path finding movement
Post by: Diarandor on July 08, 2015, 02:35:22 AM
Hi there!
I think Yruama is right. I have tested the following code and I have the same problem:

local map = ...

function switch:on_activated()
  local m
  m = sol.movement.create("path_finding")
  --m = sol.movement.create("target")
  m:set_target(map:get_entity("hero"))
  m:set_speed(64)
  m:start(NPC)
end

The NPC is on the same layer as the hero. The problem persists if I set other entity as the target. The entities are really close, so this is not a problem of distance. However, the movement works correctly if I use a movement of type "target".
Title: Re: Path finding movement
Post by: Christopho on July 08, 2015, 10:26:26 AM
Ok, I reported the bug on github since it is confirmed. Thanks Diarandor