daniu54 / earie-treasures

A 2d top-down loot-em-up with horror and stealth elements
0 stars 0 forks source link

Implement way to handle multiple `NavigationAgent2d` character sizes #31

Open Abb4 opened 10 months ago

Abb4 commented 10 months ago

Followup to https://github.com/Abb4/earie-treasures/pull/30, specifically https://github.com/Abb4/earie-treasures/pull/30#issuecomment-1676478024

Broader Discussion and problem statement: https://github.com/Abb4/earie-treasures/discussions/71

Important: If we work with NavigationMaps it is important to let the navigation server load the maps by skipping a frame:

public override void _Ready()
{
    // ...

    // Make sure to not await during _Ready.
    // see more: https://docs.godotengine.org/en/stable/tutorials/navigation/navigation_introduction_2d.html#setup-for-2d-scene
    Callable.From(ActorSetup).CallDeferred();
}

private async void ActorSetup()
{
    // Wait for the first physics frame so the NavigationServer can sync and create navigation map
    await ToSignal(GetTree(), SceneTree.SignalName.PhysicsFrame);

    navigationReady = true;
}

Here is what I could find:

Abb4 commented 10 months ago

see navmesh complexity discussion: https://github.com/Abb4/earie-treasures/discussions/71