• Hey! Guest! The 37th GMC Jam will take place between May 28th, 12:00 UTC and June 1st, 12:00 UTC. Why not join in! Click here to find out more!

Legacy GM Large Top Down World


Hello, I was wondering what methods are recommended for making AI move through a large top down world like a galaxy. I have been off an on here for a year or two now due to health issues so please excuse me for not moving on to other topics more quickly. I am still trying to learn all I can about movement AI. I have a decent understanding of some things like mp_grids and steering behaviors, but I am not sure if those are applicable to a larger scale map. I would also like some guidance on how larger maps work in game maker. How large can they be individually and can I generate infinite space or possibly scroll infinite space?


What type of simulation are we talking about exactly? When a player wants to move from one start system to another, do they perform an FTL jump, skipping the empty space between the stars? So an AI moving in similar manner would need to concern itself with pathfinding from star to star to get around. For very large and infinite-generation spaces one idea usually is that player stays in place and everything around them moves. You don't create a 50000x50000 room (or whatever), you create a room the size of the display, set player in middle, and simulate positions of other stuff by offsetting them from player by 50000 (or whatever). But I wouldn't worry about infinite spaces, it is hard enough to make smaller spaces interesting to play.


I talking about both kinds of simulations. As for infinite generation, I only want to learn how to do it, not slave away to make it polished. You mentioned one method above, are there any alternatives to this method? Your suggestion of creating the objects in space with an offset is interesting but I have a few questions. How would AI move toward you? Should I just offset their speed and direction according to the perceived player speed and direction? If so, what is the best method of movement(physics forces, a*, steering behaviors)? How would I keep the background from standing still? Possibly an animated background with multiple parallax layers that move with the speed of the room around the player?

When it comes to the other type I just wonder about how to smoothly transition. I am guessing you would move to another room that has your relative location stored according to your relative location on the map (You are in solar system x so you want to be located at solar system x on the map). Then to travel you would just start the player on a path to the next solar system using your preferred method of pathfinding depending on how your travel system works (Are there jump points like in mass effect for example.).

That is all I can think of right now as far as questions. I am working on some tactical communications with AI right now so I might have forgotten to ask a question or two. :)
Sorry if my questions are exhausting, I only want to learn. Thanks for the help!


Can anyone point me in the right direction for answers or provide any insight please? I have been working on answering my own questions by making test projects but the progress is slow. I am working on many different project files to learn different concepts and test some small games I am working on.


Friendly Tyrant
Forum Staff
Okay, let's see what we can do here...

Parallax backgrounds... easy to do in GMS2 using multiple layers and simply offsetting the layer_x and Layer_y values (there are functions for this). You would offset the different layers by different amounts based on the current player or camera position. So layer1 would be player (x,y) / 2, layer2 would be (x/y) / 3, etc... giving different "depths" to the parallax effect.

Movement... for a space game, the built in physics could work quite well, but you'll have issues with instances outside the room, so you'd be better making your own "pseudo" physics using speed, direction, etc... For the AI, you'd probably want a combination of techniques, but you can create quite complex AI using very simple code and a basic "finite state machine" system. This consists of giving the AI objects a "state" variable, and then using a "switch" function in the Step Event to parse the current state. So you'd have states like "patrolling", "attacking", "chasing", "running away", etc... and switch between them based on proximity to the player, health, capabilities, etc... The actual movement doesn't even need A* or the GMS mp grid system. Can be done with calls to point_direction, move_towards_point and angle_difference (to limit per-step rotation and give nicer movement curves when turning). Note that I wouldn't use the offset method for doing this to start with, as it's complicated and not very intuitive. Just move everything around in absolute coordinate space as you would normally. Relative movement is only useful if you are going for really gigantic spaces (over 100000 x 100000 or something). Also note that you only need a small room for this, as you can go outside the room bounds and it makes little or no difference to GM as the room space is really just a guide for level design and a few other minor things. As long as the camera follows the player, it'll look fine.

Space... If you are just beginning then an infinite world probably isn't the answer (but if you are interested, look up "chunking" on google ;) ). What I'd do is create a "hub" room where you have your over-world (over-galaxy?) with all the locations that the player can visit marked and then have them choose where they want to go. You can then make each location a room and even flag the room as persistent so that ir maintains it's state when entering and leaving. You can also create a special room for random encounters that isn't persistent and just have a controller instance in there that proceduraly generates encounters based on player level or the position in the world or the stage of the story or whatever...

Hope that helps you somewhat!


Sorry for the delayed reply, as I said above, I am suffering from some debilitating health issues right now. It takes me a while to have the energy to get back to work. I have taken your advice and put together some parallax backgrounds and they are working nicely, thank you. I am using the final version of GM:S 1.4 by the way, sorry for not mentioning that, it slipped my mind. All of your advice is sound and I thank you for it, though I have done most of what you suggested before creating this topic(excluding only the chunking system and the hub world concept). I should have also mentioned that, forgive me please. It seems I need to get better at detailing exactly what I want. I was trying to avoid an overwhelmingly long initial post that would put everyone off. Anyway, let me detail what I do know for you so that I can provide better context for advice.

My aim is for very large rooms that exceed beyond the limits of the room sizes in GM:S. My primary reasons for this are the high quality/large scale of graphics I want to implement, and the size of traversal space I would like to have with it. I am an animator by trade, so I like my HQ graphics.

I have implemented state machines, and I am prototyping several different kinds of AI with it. One of these AI is an advanced combat state machine that makes decisions based on the context of the environment. It can also avoid collision with all objects which brings me to my reason for questioning which of the movement types is best. I would like my AI to avoid collisions as intelligently as possible and dodge incoming fire. Your move_towards_point system suggestion is very sound advice for simplicity, but I am aiming for more complexity. Can I make a system that avoids collisions and dodges incoming fire with the move_towards_point system you described? I have tried and looked into it but have had no good results. I could very easily be missing something. I would appreciate any direction with this you could provide as well.

I have used your method for pathfinding with mp_grids and mp_potential_step for a long time now. It is one of the first tutorials I followed when I picked up GM:S, and I appreciate it very much, by the way. So far it works the best for most of the top down prototypes I have put together. I have not tried to use this with the offset system because I cannot imagine how that would work. Perhaps I could move it with a more simplisitc system until it enters the grid? It seems like it will only work with world chunking if I do not generate anything in negative grid space. Some advice on this would also be very much appreciated.

I have also tried steering behaviors. I have tended not to use them because I cannot get them to reliably avoid obstacles and I have not solved how to prevent the jittering it seems to cause. I am still looking around the forums for advice on this. It seems as though this would be just fine for a world chunking system if I could solve said issues above, but I am not sure how this could work with the offset solution. Maybe I could do what I suggested with mp_grids and mp_potential step and use a more simplistic movement system until I was close enough? I am very unsure about this one.

Finally I have been trying to find any kind of code example of context based steering behaviors I can because of their better ability to choose a movement direction than normal steering behaviors, but I cannot find one. I have read a lot about them and have even read the "Game AI Pro" chapter on it, but I am still struggling to come up with how to code it. Even if I did figure it out I believe I would still run into the same questions I am having about steering behaviors and mp_grids.

That is the exhausting list of why I started this thread. Sorry for it all being so long.

So you have answered my question about what methods I should use to create the worlds (either world chunking or an offset method), but I still have quite a few questions as you can see. Thanks to anyone who reads this and bigger thanks to anyone nice enough to respond or offer help. :)


Hello again! Just thought I would put this back up here because I am still looking for answers about these things. I have been trying a few things here and there but some advice would go a long way. Thanks again, any help is much appreciated.