I have successfully worked my way through the UI tutorial series and created the title screen that fades away. It works perfectly fine as it is supposed to when the game is started. The problem was that when I closed the editor then opened it again, I had to re-open the flowgraph that I created each time.
To solve this, I came to the understanding that in order for a flowgraph to save in the level, I needed to create a flowgraph module. I decided to create it as a global flowgraph module in case I wanted to use it in another level and import the flowgraph nodes from the tutorial flowgraph. This successfully allows the flowgraph to load when I open my project each time.
My current problem is that a “flowgraph module” works differently than just a loaded flowgraph. It simply will not trigger when I start game mode. I have no idea how to connect the forced module nodes into the existing tutorial flowgraph example to make it run when the game is started. There is very little information that I could find pertaining to these nodes other than stating they exist.
I have checked through each of the tutorials, tried looking through documentation, looked at CryEngine tutorials and documentation, and studied the character controller flowgraph module. No matter how I try to connect the nodes, it simply will not execute when the game starts. It still works perfectly fine if I load the flowgraph I created during the tutorial.
My questions are as follows:
- How can I get a flowgraph module to execute when the game starts?
- Where do I connect the module nodes into the tutorial nodes in order for it to work?
So after many hours of trials, google-ing, and testing, I was able to figure this out.
- Create a new prefab on the prefab tab of the Data Base View and drag it onto the level.
- Drag and drop an Entity -> Default -> FlowgraphEntity.
- Select both the prefab and the FlowgraphEntity then on the main menu select Prefabs -> Add Selected Object(s) to Prefab.
- Select the prefab, then in the RollupBar (on the right by default) click the “Open All” button listed in the Global Prefab Parameters. This allows you to select the FlowgraphEntity separate from the prefab.
- With the FlowgraphEntity selected, locate the Flow Graph section in the Rollup Bar and click the “Create” button. Give this a group name that suits its functionality. This will create and attach a flowgraph to the FlowgraphEntity that we will need in order to execute our flowgraph when the game starts.
- In the newly created flowgraph add a Game:Start node.
- While still in the flowgraph editor click File -> New FG Module -> Global. Once again, give this a suitable name for its functionality. This will be where we add our logic to handle the UI (or anything else you want for that matter).
- With the Global Flowgraph Module highlighted, click on File -> Save (or control + s).
- Go back to the flowgraph you created on the FlowgraphEntity, then add a Module:Call_ node.
- Connect the output from the Game:Start node to the call input on the Module:Call node. (NOTE: We are now done with this flowgraph and it does not need to be saved as a flowgraph XML file because this information will be saved within the prefab. This flowgraph exists only as a way for us to execute a flowgraph when the level starts because it HAS to be attached to an entity within the level in order to do so. This is important!)
- Go back to the Global Flowgraph Module and add the rest of the nodes that you wish to be executed. Simply treat the Module:Start node’s Start output the same way you would normally treat the Game:Start node’s Output output. Once you are done creating and connecting nodes here, click File -> Save (or control + s).
- Close the Flowgraph Editor.
- Select the FlowgraphEntity you created earlier and added to the prefab. Move it to a position that is close but not on top of the prefab in order to find it again later.
- Once you are happy with its position relative to the prefab, s****elect the prefab only, then in the RollupBar (on the right by default) click the “Close All” button listed in the Global Prefab Parameters. This will save the FlowgraphEntity (and its associated flowgraph) as part of the prefab XML file.
- Start your game (control + g) to test if the Global Flowgraph Module executes as desired and edit as necessary.
Remember, even though the module is Global, it will only be called if the prefab you created exists somewhere in your level. Also, since it is a prefab, and the module you created is Global, these are portable between levels and projects!
I hope this helps and saves someone else the trouble of having to figure it out! One suggestion I would offer is to add this set of instructions somewhere into a tutorial and do something similar to other tutorials as well. Having global modules, prefabs, and gems is great for getting started quickly, but offers no understanding for how these things work.