Planning Motion with Object Nodes
by Matt Thorson
Contents
1. What Are Nodes?
Let's say we're making a game with lots of moving platforms. We want these moving platforms to move along a set path, but each platform can have its own unique path. In addition, some of these paths could be really simple (from point A to point B and back), but some could be more complicated (point A to B to C to D then back to A, etc). Object nodes help us plan out these paths in a visual way inside the editor. Planning motion definitely isn't the only use for nodes, but it's what they were designed for.
Nodes have only a position (x and y), and live inside an object. One object can have many nodes.
2. Basic Nodes
Let's start by opening up the Ogmo Editor example project. The example project is copied to your hard drive when you install the editor, in its application folder. On Windows this defaults to "Program Files/OgmoEditor". Open the "exampleProject.oep" file in the editor.
Switch to the "objects" layer and select the "moving_platform" object in the object selector window (it's the gold-colored block, third object from the left). Place one moving platform in the level. Now switch to the "Nodes" tool (last tool on the right, or just press the R key). The moving platform you placed should still be selected. If it isn't, go back to the "Select" tool and click it then switch back to the "Nodes" tool.
Now we can left-click to place nodes for this instance of the moving platform object. We can right-click nodes to delete them. While using the "Nodes" tool, the DELETE key deletes all the currently selected object's nodes. The moving platform in the example project has a limit of three nodes - if you place more it will delete the oldest to make room for the newest.
3. Node Settings
Let's look in the project file and see how these nodes are defined. Open it in your text editor and you should see...
I've highlighted the area of interest above. Reading it, you'll see that the <nodes> tag resides within the <object> tag that the nodes will belong to. You'll also see that objects can have both nodes and values. The <nodes> tag actually has no required attributes.
The drawObject attribute tells the nodes whether or not to draw a ghost of the parent object at their position. This is useful for seeing how objects will fit in relation to nearby objects as they move, but could also just be clutter if your levels have a lot going on. The limit attribute works exactly like it does in the <object> tag. Give it a number and it will make sure that any instance of the parent object will have no more than that amount of nodes. There's also a color attribute which lets you set the color of the lines and dots of the nodes (they default to yellow).
Finally, there's the lineMode attribute. There are four choices for line modes, defined by integers: None (lineMode="0"), Path (lineMode="1"), Circuit (lineMode="2"), and Fan (lineMode="3"). The default is None (lineMode="0"), which simply means no lines will be drawn between nodes.
In Path Mode (lineMode="1"), lines will be drawn from the parent object to each node in order. The example project nodes are in Circuit Mode. In Circuit Mode (lineMode="2"), lines will be drawn from the parent object to each node in order, and then the last node also reconnects to the parent object. In Fan Mode (lineMode="3"), lines will be drawn from the parent object to each node.
4. Node Output
Nodes only output their x- and y-positions, and nothing else. Here's a simple level file from the example project with some nodes.
As you can see, the nodes simply output their positions as child tags within their parent object's tag. It's worth noting that they are output in order from first-placed to last-placed.


