Behaviour tree not working

#1
Documentation show code for a basic template with code that that is not defined so i mixed part of it with the registration method from gamesdk but it is still not working(code won't compile)

Code: Select all

#ifndef _BEHAVIOURTREE_H
#define _BEHAVIOURTREE_H
#include "AI/BehaviorTreeNodes_Action.h"
#include "AI/AIGroupProxy.h"
#include "AI/AIProxyManager.h"
#include "AI/CommunicationHandler.h"
#include <CryAISystem/BehaviorTree/Node.h>
#include <CryAISystem/BehaviorTree/NodeFactory.h>

using namespace BehaviorTree;

namespace BehaviorTree { struct INodeFactory; }

void RegisterGameBehaviorTreeNodes();
class CBehaviourTreeNode : Node
{
typedef BehaviorTree::Node BaseClass;
public:
// Every instance of a node in a tree for an agent will have a
// runtime data object.
//
// This data is persistent from the point when a node is visited
// until the point when it's left.
//
// If this struct is left out the code won't compile.
//
// This would be variables like 'bestPostureID', 'shotsFired' etc.

struct RuntimeData
{

};
CBehaviourTreeNode(): m_speed(0.0f)
{}

// This is where you'll load the configuration data from the XML file
// into members of the node. They can only be written to during the loading phase
// and are conceptually immutable (read-only) later while the game is running.

virtual BehaviorTree::LoadResult LoadFromXml(const XmlNodeRef& xml, const BehaviorTree::LoadContext& context)
{
if(BaseClass::LoadFromXml(xml,context )== BehaviorTree::LoadFailure)
{
return BehaviorTree::LoadFailure;
}
xml->getAttr("speed", m_speed);
return BehaviorTree::LoadSuccess;

}
protected:
// Called right before the first update
virtual void OnInitialize(const BehaviorTree::UpdateContext& context)
{
BaseClass::OnInitialize(context);
// Optional: access runtime data like this
RuntimeData& runtimeData = GetRuntimeData<RuntimeData>(context);
}
virtual BehaviorTree::Status Update(const BehaviorTree::UpdateContext& context)
{
// Perform your update code and report back whether your
// node succeeded, failed or is running and needs more
// time to carry out its task.
// Optional: access runtime data like this
RuntimeData& runtimeData = GetRuntimeData<RuntimeData>(context);
return BehaviorTree::Success;
}
// Handle any incoming events sent to this node
virtual void HandleEvent(const BehaviorTree::EventContext& context, const BehaviorTree::Event& event)
{
// Optional: access runtime data like this
RuntimeData& runtimeData = GetRuntimeData<RuntimeData>(context);
}
private:
// Store any configuration data for the node right here.
// This would be immutable things like 'maxSpeed', 'duration',
// 'threshold', 'impulsePower', 'soundName', etc.
float m_speed;
};



BehaviorTree::INodeFactory& factory = gEnv->pAISystem->GetIBehaviorTreeManager()->GetNodeFactory();

#endif

cpp
void RegisterGameBehaviorTreeNodes()
{

assert(gEnv->pAISystem->GetIBehaviorTreeManager());

IBehaviorTreeManager& manager = *gEnv->pAISystem->GetIBehaviorTreeManager();

REGISTER_BEHAVIOR_TREE_NODE(manager, CBehaviourTreeNode);
}
Last edited by CryOxCom on Tue Nov 14, 2017 12:09 pm, edited 1 time in total.
Reason: syntax highlight feature = on

Who is online

Users browsing this forum: No registered users and 2 guests