Trigger C++ From Flowgraph doesn't work

#1
Hi all.
I'm on CryEngine 5.6 and flowgraphs. I'm at the point that I need to trigger C++ from flowgraph and to do this I've followed the instruction in this documentation page https://docs.cryengine.com/display/CEPR ... ent+System

This page seems quite not updated (last update 5 years ago LOL), it talks about Game.h/cpp instead of GamePlugin.h/cpp (I guess). Unfortunately the implementation described in the documentation doesn't work at all and I really don't know what I?m missing since I've brutally copied and pasted all the code from the documentation to my game, which is the Third Person Demo project. (I've put the UIFunctions files in the Components folder and the code of the Game.h/cpp section in the GamePlugin.h/cpp files, since the former doesn't exist anymore...)
Does anybody know if there's some missing information in the documentation?

thanks.

Re: Trigger C++ From Glowfraph doesn't work

#2
Hi Evethir,

If all you wish to do is call C++ functions from FlowGraph you do not need any of these UI Actions.
Most FlowGraph nodes (With the exceptions of dynamic - ui - and LUA entities) are plain C++.

To create FlowGraph nodes and expose them from your template project (or any CE Plugin), you will need to:

1. Add the Flowgraph Registration/Deregistration Macro to the plugin interface:

Code: Select all

PLUGIN_FLOWNODE_REGISTER
PLUGIN_FLOWNODE_UNREGISTER

2. Create your FlowGraph Node by inheriting from IFlowBaseNode. Simple Flownode Example;

Code: Select all

// MyFlowNode.h

#include <CryFlowGraph/IFlowBaseNode.h>

class CMyFlowNode : public CFlowBaseNode<eNCT_Singleton>
{
public:
virtual void GetConfiguration(SFlowNodeConfig& config)
{
static const SInputPortConfig inputs[] = {
InputPortConfig_Void("Execute", _HELP("Execute calculation")),
InputPortConfig<float>("Input A"),
InputPortConfig<float>("Input B"),
{ 0 }
};
static const SOutputPortConfig outputs[] = {
OutputPortConfig<float>("Result"),
{ 0 }
};

config.pInputPorts = inputs;
config.pOutputPorts = outputs;
config.sDescription = _HELP("Adds A to B and returns result");
config.SetCategory(EFLN_APPROVED);
};

virtual void ProcessEvent(EFlowEvent event, SActivationInfo* pActInfo) override
{
switch (event)
{
case eFE_Activate:
{
if (IsPortActive(pActInfo, 0))
{
const float result = GetPortFloat(pActInfo, 1) + GetPortFloat(pActInfo, 2);
ActivateOutput<float>(pActInfo, 0, result);
}
}
}
};

virtual void GetMemoryUsage(ICrySizer* s) const {};
};

3. Register your Flow Node;

Code: Select all

// MyFlowNode.cpp

#include "MyFlowNode.h"
REGISTER_FLOW_NODE("CustomNodes:MyCustomNode", CMyFlowNode);

Now when you compile and start your project you should see the new Flow Node.
Let us know if you have any issues.
Uniflare
CRYENGINE Technical Community Manager
Here to help the community and social channels grow and thrive.

My personal belongings;
Beginner Guides | My GitHub | Splash Plugin

Re: Trigger C++ From Flowgraph doesn't work

#4
1. How do I do the first point you described?
In your Plugin Interface (class CGamePlugin) you add these two lines. For example;

Code: Select all

...
CRYINTERFACE_SIMPLE(Cry::IEnginePlugin)
CRYGENERATE_SINGLETONCLASS_GUID(CGamePlugin, "RollingBall", "{24FE22B8-4592-440B-8E9C-BA5E6F22F721}"_cry_guid)

PLUGIN_FLOWNODE_REGISTER
PLUGIN_FLOWNODE_UNREGISTER

virtual ~CGamePlugin();

// Cry::IEnginePlugin
virtual const char* GetCategory() const override { return "Game"; }
virtual bool Initialize(SSystemGlobalEnvironment& env, const SSystemInitParams& initParams) override;
// ~Cry::IEnginePlugin
...
2. What's the sense of that documentation page? This is very missleading ...
This page is for the Flash UI Event System and is geared towards the implementation found in the GameSDK. These can be used to trigger events in FlowGraph from C++ and Dynamically (at runtime) create FlowGraph nodes that can call functions in C++. Here is a more relevant documentation that doesn't rely on GameSDK for the node itself: https://docs.cryengine.com/display/SDKD ... +Flow+Node - however, it is missing the first step I mentioned when implementing this inside plugins.


I should mention you will need to include IFlowBaseNode.h from CryCommon in the MyFlowNode.h. I have updated the original reply to reflect this.
Uniflare
CRYENGINE Technical Community Manager
Here to help the community and social channels grow and thrive.

My personal belongings;
Beginner Guides | My GitHub | Splash Plugin

Who is online

Users browsing this forum: No registered users and 4 guests