Set grid cost modificator?

  • July 7, 2017 at 15:36 #21261
    exltus
    Participant

    Hi, is somehow possilbe to set specific cost to specific grids runtime?

    July 10, 2017 at 10:19 #21292
    Rami
    Keymaster

    Hi Exltus,

    Thanks for your post.

    You should be able to simply iterate through the cells of a grid and assign any cost value, given a grid reference. There should not be any issues in doing so.

    July 11, 2017 at 15:06 #21329
    exltus
    Participant

    Thx for answer. But i have another one questin. Is somehow posssible to find path, that is ignoring cell costs? We need to create some specific enemies, that will move to target regardless of cell costs…

    July 11, 2017 at 15:43 #21331
    Rami
    Keymaster

    The current implementation of grid cost fields is very simple, and thus applies equally to all navigating units. Therefore there is no built-in provided option for differentiated costs. You can however implement this yourself, since you have full source code access to Apex Path.

    July 14, 2017 at 12:11 #21364
    Geminior
    Keymaster

    One small additional note is that preparations are made for it in code, but are not implemented. Look for the ICellCostStrategy interface and the one implementation of it.

    July 27, 2017 at 10:44 #21513
    exltus
    Participant

    Thx for answers. Everything is working well at runtime. But now I am facing problem, that I need set and serialize cost of specific grids at edit time. Any suggestion?

    July 31, 2017 at 16:25 #21557
    Rami
    Keymaster

    We haven’t worked specifically with serialization of grid costs. Thus, I don’t have any “production/tested” suggestion.

    However, there should be no major issues. Just serialize however you want, e.g. to JSON or using Unity, and then read the data at start. Obviously, you will need ways to identify the right grid and so.

    You will have to write this yourself though, since no such support is provided out of the box. If you own Apex Utility AI, you can use the ApexSerialization attribute and thus leverage the powerful JSON serialization that is provided with Apex Utility AI.

You must be logged in to reply to this topic.