NoRouteExists with Unit Attributes and runtime portal

  • January 8, 2018 at 03:32 #22614

    Hey, hope you’re doing well! I’ve recently started playing around with unit attributes – I want to set it so that certain units can’t use elevators.

    I created the Attributes object with a Can Use Elevator attribute. I went ahead and set up my logic so that my runtime portals will have the Can Use Elevator attribute applied to exclusive to.

    Now here’s the interesting part – the path callback rightly says no path exists when a unit that can’t use elevator is outside of the elevator and the target is inside of the elevator.

    Here you see the component which applies the attributes to the portal at runtime, as well as the code behind it:

    Showing Applies field on elevator door component which applies unit attributes to portal at runtime

    The code that does the applying at runtime

    Runtime portal

    I wrote a HandleNoRoute function to handle this, but for some reason, GetNearestWalkableCell is returning a cell as walkable inside the elevator, instead of the closest cell next to the portal on the outside of the elevator. This causes an endless loop of HandleNoRoute()

    Custom HandleNoRoute() function

    Does GetNearestWalkableCell() not take portals / unit attributes into account?

    January 8, 2018 at 11:06 #22616

    You are correct that GetNearestWalkableCell() does not take portals into account it just samples cells around the origin.

    What you could do instead of using a portal, is to mark the elevator with a Dynamic Obstacle.
    Add a gameobject and add a box collider to it. Set the collider to trigger only. Add the Dynamic Obstacle component and set its Update Mode to OnRequest and its Exceptions Mask set to ‘Can Use Elevator’.
    Scale the Gameobject so that it covers the elevator area.

You must be logged in to reply to this topic.