[Tool] Graph Creation Tool

This is a tool to visualize a graph and ease the creation. It is mainly a tool for my graph-based pathfinding resource: [Resource] Graph-based Pathfinding Algorithm for Dummy Bots
The graph defines where the dummy bots are walking. So be careful when creating it.

Share Code: MVZE1 - Version 1.2

What is a graph? A graph can be imagined as a network. It consists of a set of nodes, wich are connected by edges.
For an Overwatch-navigation-graph this would mean nodes are positions on the map a bot can walk to and edges are connections between them, if a bot can walk from one position to another. If a bot can't walk between 2 positions, they are not connected by an egde.

How is the graph type implemented in workshop? The nodes are an array of position vectors.
The edges are an array of vectors in this structure: vector(node1, weight, node2)
- node1: This is the index of the node in the nodes array the bot is coming from.
- node2: This is the index of the node in the nodes array the bot can walk towards.
- weight: This number represents how long the way from one node to the other is. If it's 0 it doesn't mean that the way is free, but that it's an unweighted (= undefined weight) edge.

How to visualize a given graph:

  • Copy the “nodes” array into the rule “Nodes”
  • Copy the “edges” array into the rule “Edges”
  • Start the game
  • The green spheres are the nodes
  • The blue beams are the weighted edges (Y component > 0)
  • The red beams are the unweighted edges (Y component = 0)
  • Edges are a bit higher on the one end and a bit lower on the other end. This means that the egde is coming from the higher end (this is the node in the X component of the vector) and is going towards the lower end (this is the node in the Z component of the vector)

How to create a new graph:

  • Start the game
  • Adding a new node
  • Go to the position of the node you want to add
  • Press primary fire to create a new node
  • The new node is a blue sphere, wich means that it has just been created
  • If you don’t like it you can press interact to remove it. You can only remove the last created node. If you press primary fire 2 times you can’t remove the first one with interact, only the second
  • Go close to the new node and press ultimate to teleport directly to its position
  • Open workshop and add a similar line to the Nodes rule: set global variable at index(nodes, *next free index*, vector(0, 0, 0))
  • When adding the “vector” value, press the button with the camera and the little red circle
  • Repeat until you have all the nodes you want (you can also add new nodes any time)
  • IMPORTANT Make sure that there is no “0” in the nodes array, as this will break the pathfinding algorithm
  • Adding a new edge
  • Go close to the first node you want to connect. Press Secondary Fire. Write down the number or keep it in mind. I reference it as “node1” here.
  • Go close to the second node you want to connect. Press Secondary Fire. Write down the number or keep it in mind. I reference it as “node2” here.
  • Open workshop and add a similar line to the Edges rule: set global variable at index(edges, *next free index*, vector(node1, 0, node2))
  • Keep in mind that you also have to add a second edge vector(node2, 0, node1) if you want the edge to be walkable in both directions
  • Setting the weight of an existing edge
  • Go close to the first node of the edge. Press Crouch.
  • Go close to the second node of the edge. Press Crouch again.
  • Now the message will display with the index of the edge and the weight.
  • Open workshop and look for the edge with the index in message, then set its Y component to the weight.
  • If the egde you have chosen doesnt exist, the index in the message will be -1, or the index of the first element in the array that is 0.
  • Removing an edge
  • Chose the edge with crouch like before.
  • You can freely remove it from the array.
  • Removing a node
  • Don’t just remove the node from the array. It will be replaced by a 0 and this will break the pathfinding algorithm.
  • Remove all the edges the node is connected with first.
  • Then, instead of removing it, you change the Y component of the node you want to remove to a very low value. It has to be underneath the ground, so it will never be chosen by the pathfinding algorithm.

Top-Down Camera Controls:

  • Press reload to start the top-down camera.
  • Hold ability 1 (shift) and move the mouse / control stick to rotate the camera.
  • Hold ability 1 (shift) and move forward / backward to zoom the camera in / out.
  • move left / right / forward / backward (don’t hold ability 1) to move the camera around.
  • Press reload again to leave the top-down camera.

Selecting a specific area of the graph:

  • As there is an effect limit of 128 effects, a graph that has more than 128 elements (nodes + edges) can’t be visualized entirely. So I added the option to select a specific area on the map and show only the elements wich are inside this area. This is how to do it:
  • Press reload to enter the top-down camera.
  • Move / zoom / rotate the camera.
  • You will notice a violet circle on your screen. This is the cursor position you can simply control with the mouse / control stick.
  • Press primary fire to select the center position of the area at the current position of the cursor. A yellow heart will mark the center position.
  • Press secondary fire to cancel the area selection.
  • The area gets visualized by a yellow light shaft. Move the cursor to change the size of the area. Press primary fire again to confirm the area selection.

Hardcode an area you are frequently working on:

  • If you are working on a specific area of the graph and you don’t want to select the area every time you restart the match, you can hardcode the area this way:
  • Check the inspector for the player variable “areaPhaseCenterRadius”. This array holds the center position of the currently selected area at index 1 and the radius at index 2.
  • Open the rule “initialisation”.
  • Activate the disabled actions and enter the center position and radius exactly like commented.

Change-Log:

  • Version 1.2
  • Added top-down camera option
  • Added option to show only a specific area of the graph

I hope you will like this tool. If you have any feedback, please share it with me :slight_smile:

3 Likes