Topic: access to the "Follow behavior" attributes

Hi, I have an another question about SDK, I try to attach a Follow behavior to a 3d Entity :

MBehaviorManager * bManager = MEngine::getInstance()->getBehaviorManager();
MBehaviorCreator * bCreator = bManager->getBehaviorByName("Follow");
MBehavior * behavior = bCreator->getNewBehavior(object);
object->addBehavior(behavior);

it work, but how can I change the "delay", "offset" ... attributes of "behavior" ?
I try to convert "behavior" with an expression like "(Follow *) behavior" but it doesn't work ...

Last edited by Alinor (2012-01-31 18:15:50)

Re: access to the "Follow behavior" attributes

Hi,
yes, you don't have access to the MBFollow class from the SDK,
the generic system to access to behavior variables is this :

MVariable variable = behavior->getVariable(0); // first variable ("target")
MString * target = (MString *)variable.getPointer();

behavior->getVariable(1); // "delay"
float * delay = (float *)variable.getPointer();
...

if you are not sure of the variable id, name or data type, you can scan the variables :

variables number :
unsigned int nbVar = behavior->getVariablesNumber();

name :
variable.getName();

type :
variable.getType();
(can be M_VARIABLE_BOOL, M_VARIABLE_INT, M_VARIABLE_VEC2, M_VARIABLE_VEC3...)

Re: access to the "Follow behavior" attributes

Ok, thanks wink