Wie funktioniert >Pathfinding<?

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Wie funktioniert >Pathfinding<?

    Hallo,
    ich weiß nicht ob es schon ähnliche Fragen gab und genauso wenig weiß ich wo ich eine Antwort finden kann.
    Also: Wie kann ich machen das ein Objekt in einem Labyrinth den (kürzesten) Weg zum anderen Ende findet und entlang 'fährt'. Ich glaube das heißt >Pathfinding<, aber mehr weiß ich nicht.
    Ich bitte um Hilfe,
    maxda

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von maxda ()

  • Im Gamemaker wird es nicht Pathfinding sonder Motionplanning genannt. Die benötigten Funktionen fangen alle mit mp_ an. Dabei wird immer ein Raster erstellt, in welchem danach die begehbaren und unbegehbaren Stellen eingetragen werden. Diese Funktionen wirst du wohl brauchen:
    mp_grid_create(left,top,hcells,vcells,cellwidth,cellheight) This function creates the grid. It returns an index that must be used in all other calls. You can create and maintain multiple grid structures at the same moment. left and top indicate the position of the top-left corner of the grid. hcells and vcells indicate the number of horizontal and vertical cells. Finally cellwidth and cellheight indicate the size of the cells.

    mp_grid_add_instances(id,obj,prec) Marks all cells that intersect an instance of the indicated object as being forbidden. You can also use an individual instance by making obj the id of the instance. Also you can use the keyword all to indicate all instances of all objects. prec indicates whether precise collision checking must be used (will only work if precise checking is enabled for the sprite used by the instance).

    mp_grid_path(id,path,xstart,ystart,xgoal,ygoal,allowdiag) Computes a path through the grid. path must indicate an existing path that will be replaced by the computer path. xstart and ystart indicate the start of the path and xgoal and ygoal the goal. allowdiag indicates whether diagonal moves are allowed instead of just horizontal or vertical. The function returns whether it succeeded in finding a path. (Note that the path is independent of the current instance; It is a path through the g rid, not a path for a specific instance.)
    int (*x(*x(int))[5])(int*);
    Confused? Yes, it's C!