Topic: How to add an object Behavior in C ++?
I have tried many ways to add Behavior LookAt a camera but no way it works, how it is done?
You are not logged in. Please login or register.
I have tried many ways to add Behavior LookAt a camera but no way it works, how it is done?
Hi, start with this tutorial :
http://www.maratis3d.org/?p=500
If you just want to add a behavior to an object in c++.
You can use the behavior manager if you don't have access to the behavior code directly:
MEngine *engine = MEngine::getInstance();
MBehaviorManager * bManager = engine->getBehaviorManager();
MBehaviorCreator * bCreator = bManager->getBehaviorByName("LookAt");
MBehavior *behavior = bCreator->getNewBehavior(object);
object->addBehavior(behavior);
MVariable var0 = behavior->getVariable(0); // var 0 is "target"
MString *targetName = (MString *)var0.getPointer();
*targetName = "objetNameToLookAt";
If you have access to the behavior class you can do this directly:
MBLookAt *behavior = MBLookAt::getNew(object);
object->addBehavior(behavior);
Powered by PunBB, supported by Informer Technologies, Inc.
Currently installed 3 official extensions. Copyright © 2003–2009 PunBB.