• 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!

Objects VS Tilemap Collisions with Enemy Pathing

V

viater

Guest
I've been working on a top down RPG. The perspective is like 'Titan Souls'. I did my own collisions for my player with the tile map and it worked pretty well, I wanted to be able to build levels more easily than placing objects for every wall and the tile map collisions are fast. But now I've realized, that by making the tile map collisions, I cannot easily add in enemy pathing through the room.

If there are objects in the room for the walls you can use the mp_grid and its pretty simple. Also, there are left and right facing ramps that the player moves diagonally on as far as the game is concerned which enemies should mimic. I wouldn't know how to do with the mp_grid method anyway.

I'm not opposed to scratching what I've done already for a better method, I just do this for fun.

So can anyone help point me in a better direction for enemy pathing without adding a bunch of wall objects?
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
I cannot easily add in enemy pathing through the room.
Why not? Simply loop through the collision tilemap and if there is a tile, add a cell to the mp grid. Alternatively, just mimic how the player does it in the AI. So, instead of checking for the right arrow (for example), you'd simply have the enemy AI set a right-arrow variable and then check t and move right in the code.
 

NightFrost

Member
You can fill an mp grid from whicever resource you want. A procgen dungeon project of mine first lays down its stuff into an array and then copies the wall parts to mp grid via mp_grid_add_cell. Ramps might be a problem as their diagonal collision shape can't directly be represented on a grid. In a-star pathfinding, what mp grid represents to you as an idea of a grid, the actual mechanic is nodes (points) connected by edges (lines) with area not entering the equation. They're simply considered equal sized square cells in representation, owing to equal distance between all nodes and edges connecting them at right angles. You may need to cheat with actual object collisions and make sure the only connection between ramp grid cells can be diagonal. Paths given out by mp grid always route through centers of cells so while enemies are simply following them they won't pathfind into walls, as opposed to when they're seeking towards player (they need to leave the path when trying to attack, and these close quarters combat's collisions can't be helped by pathfinding).
 
Top