The Timeline Editor

The Timeline EditorIn most games you will want certain things to happen at precise moments in time. Now, you can try to achieve this by using the alarm events but when things get too complicated this won't work any more, especially as you are limited to only twelve alarms. That's why we have the timeline asset. In a timeline you specify which actions must happen at certain moments in game time, and you can use all the actions that are also available for an object in its different events or code to define this. Once you create a time line you can then assign it to an object, and the instance of that object will then execute the actions at the indicated moments of time when placed or created within a room.

For example, assume you want to make a guard and that this guard should move 20 time steps to the left, then 10 upwards, then 20 to the right, then 10 downwards and then finally stop. To achieve this you can make a timeline where you start with setting a motion to the left. You would then create moment 20 (a "moment" is just another way of saying "game step" or "game frame") and set a motion upward, then at moment 30 a motion to the right, at moment 50 a motion downwards and finally at moment 60 you would stop the motion. Once that is done, you can assign this timeline to the guard object and the guard instance will do exactly what you planned when placed in a room. You could even set an alarm in the time line so that it is repeated after a certain length of time and in this way your guard can patrol an area. You can also use a time line to control your game more globally, for example by creating an invisible controller object, then a time line that at certain moments creates enemies, and then assigning it to the controller object and placing an instance into the room. This is an easy way to get timed spawns of the enemies in a space shoorter game or something like that.

On adding a new moment, you may be asked to choose between GML Visual and GML Code. See GameMaker Language for more information.

To create a time line, right click RMB Icon on Asset Browser and select "Create Timeline". This will open the window pictured at the top of this page with the following sections:

 

NameName

Here you give your timeline resource a name. This must only contain alpha-numeric characters or the "_" under-bar and cannot start with a number, as it will be used to reference your timeline through code. This name will also be the unique timeline ID which can be used in GML Visual actions or code functions to identify the timeline.


MomentMoment

You can set the moment value here. The moment value is calculated as the number of game steps after the timeline has started. So if you have a timeline with moments at positions 0 and 60, then moment 0 will be triggered when the timeline is started and moment 60 will happen 60 steps later. If your room speed is set to 60 too, then moment 60 will happen one second after the timeline is started. You can do a double click LMB Icon on the moment value or you can use the right button RMB Icon menu and select " change" (see the section on the button menu below) to change it. To add a new moment, simply click the Add button at the bottom of the editor. Adding new moments will open the code editor (or action editor) where you can add the functions or GML Visual that you want to call in that moment.


Moment NameMoment Name

To help you understand what your timeline is doing it is permitted that you give moments a name to identify them. This is simply a string and will not be used in the game code or anywhere else, as it's purely for organising and understanding what your timeline does. To add a name/description to your moment, you need to use the /// @description format on the first line of the code block, for example:

/// @description Hello World

Which would look like this:

Timeline Editor Name/Description

 

The timeline editor permits you to use Space Icon + LMB Icon to select all moments between the first click LMB Icon and the second click LMB Icon, or you can use Control Icon / CMD Icon + LMB Icon to click on single moments to select them independently. Timeline moments can be edited using the right mouse button RMB Icon menu on one of the selected elements:

Timeline RMB Menu