Multidirectional Graph

After further thought on the graph’s design, I needed to determine a more efficient way for designers to set up the graph than simply having each spline select every single spline they connect to. That approach would be prone to more mistakes and would result in more wasted time.

In an attempt to solve this, I started designing an additional blueprint that would represent a node holding all the splines (edges) that could traverse to one another. However, I didn’t like this design because it added an extra blueprint that would have to be placed in the level.

I went back to the original idea of having each spline hold two separate arrays, one for each endpoint. However, I wanted to explore whether Unreal’s construction script can automatically detect when an element is added with the picker tool and then automatically add it to the other splines if their references aren’t already present.

After receiving feedback from a Level Designer regarding the workflow, they expressed their belief that this workflow would be sufficient. In the future, I will have the Level Designer test the system to gather feedback on how it can be further improved for a better workflow.

In the construction script for the splines, I added a function that automatically updates the two sets (not arrays) for any other connected spline edge. This is a convenient functionality. However, currently, it does not handle the automatic removal of a spline edge if another one removes it. Ideally, automatic removal would be great, but unfortunately, I don’t have the time to implement it at the moment. Additionally, I switched to using sets instead of arrays because it would be more convenient to have the edges as keys for easy lookup.

However, there is a flaw in this design. It assumes that whenever the first node of a spline is selected, the connecting splines must be the last nodes. However, this assumption may not always be true, so the system needs to provide more flexibility to ensure correctness. This becomes particularly important if we consider that the player may be able to face in either direction while on the spline. To address this, we can add a Boolean variable to allow the player to face the other direction instead.

Since I want the player to be able to look towards a spline and press E, I need a way to recognize if they are facing the correct direction. However, the initial issue is that the splines themselves don’t generate hit events, rendering the sphere trace that I tried to use ineffective.

Above is an image of my successful attempt at getting the sphere trace to work. The solution involved using the instanced static meshes generated from the construction script for hit detection.

The above image also demonstrates that the spline can be detected correctly even if the instanced static meshes are hidden in the game.

Then, I modified the player event graph to successfully detect when you are pointing at a valid spline that can be jumped towards when you reach one of the end spline points. This allows the player to jump towards multiple splines. The result can be seen in the video above.

Lastly, I realized that I didn’t need to loop through an array from the sets. Instead, I could use the “contains” node to determine whether the spline existed. This is more efficient, as it should be a constant time lookup instead of the unnecessary linear lookup.

What’s Next?

I will begin implementing Dijkstra’s Algorithm and setting up the graph system to allow AI to utilize the pathfinding algorithm.