• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code AI and tilesets

T

Tempus

Guest
Hello everybody,

In the context of mp_potential functions I have some questions which are in Game Maker Studio 2 maybe easy to solve.

For the player-controlled object there are many ways to detect collisions with obstacles (e.g., tilemap collision, gridbased, physics)

For the simple opponents AI with mp_potential functions there is apparently only the possibility of objects. If I want to move an opponent through a labyrinth the labyrinth must consist of objects.

Question:
Can you use mp_potential functions to move enemies through a tilebased labyrinth?
Is there the possibility to combine mp_potential functions with physics. Especially if the player tries to run through a group of opponents.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
You do not need instances to create an mp_grid. You can flag any grid cell in an mp grid as "occupied", and there is no reason why you can't use a tile layer to get the cells to flag. http://docs2.yoyogames.com/source/_build/3_scripting/4_gml_reference/movement and collisions/motion planning/mp_grid_add_cell.html

Physics is more complex due to the fact that it uses a movement system that is 100% different to the general system that the mp functions (and other movement functions) use. It can be done, simply get the path and then set the phy_position_x/y values to the correct position along it. However it may give odd results..
 

c023-DeV

Member
The mp_grid functions are independant, you set them up separately (they can also be in a different resolution).

I still create invisible objects and optimize them. I do my collisions against the tilemap. But I use the collision line to see if a player is in view and use mp_potential for direct maneuvers.
These functions require objects. I also have a mp_grid set up for mor complex AI navigation tasks, but it only gets used by certain enemies.

But if someone could point me to a fast collision_line() function for tilemaps ...that 'could' be cool for AI... =)
 
T

Tempus

Guest
I'm not shure i explained it right.
I don't use the mp_grid functions. I wan't to use the mp_potential_step. This makes it easier to avoid collisions with multiple enemies. They don't intersect each other.
 

c023-DeV

Member
I'm not shure i explained it right.
I don't use the mp_grid functions. I wan't to use the mp_potential_step. This makes it easier to avoid collisions with multiple enemies. They don't intersect each other.
Yes, and that requires 'invisible' objects if you want them to avoid walls too. And it's a good idea to optimize these objects so you don't have an object per tile but rather stretch them to cover multiple tiles.

The mp_grid functions are for complex navigation. Like tracking the player in a tight labyrinth. And you can also mix the two! By using the potential functions to navigate to the path-points that are generated through the mp_grid functions (that way they can also avoid each other) but that is mostly not needed in my case...

But overall I guess you were asking if one could use the tilemap data for mp_grid functions, and the answer is; No, you have to set up the mp-grid independently. And to use the mp_potential functions you need objects.
 
T

Tempus

Guest
Sad that we have all the fast and fancy possibilities for the player object but the enemie movement still need objects and can't use physics.
 

c023-DeV

Member
Sad that we have all the fast and fancy possibilities for the player object but the enemie movement still need objects and can't use physics.
Well, it all depends on what you are doing. For very simple stuff you can do your own 'pathfinding' or easy checks against the tilemap with tilemap_get_at_pixel() and then let the enemy move. In a lot of cases that should be fine and efficient.

And unless you require weight and simulation environments then physics is mostly an overkill and not the only way to go for most game mechanics.
 
S

steveyg90

Guest
I was thinking about this too. I'm using timemap_get_at_pixel for my player collision with walls etc, guess I could use the same code for the enemy collision with walls but of course, lose the functionality of mp_potential functions due to having to use objects for these...

I think using tile based collision is cool, but if wanting to use mp_ functions I think I would stretch an object over the walls, would this be the way to go?
 
T

Tempus

Guest
I'm in the same boat. I too want to use the mp_functions. I don't see a way to use this with tilemap collision. Using tilemap collision and objects for mp_functions seems to be a no speed advantage. So i use tilesets for the floor of my random generated dungeon and objects for the walls. So i do it like in classic game maker.

But i'm just a beginner with game maker.
 
Top