BehaviorInstance::getTemplateName returns null
by And Yet It Moves · in Torque Game Builder · 07/13/2007 (6:17 am) · 2 replies
Hi,
since i switched to 1.5 release my behaviors behave rather weird (some behavior methods can't be found, i did not yet check which exactly are broken, we have many nested behaviors...). my first guess is that it has something to do with getTemplateName() always returning null?
[edit1]
i just saw that BehaviorTemplate::createInstance returns a BehaviorTemplate instead of a BehaviorInstance. thats why calling getTemplateName on the returned object doesnt work...
doesnt the BehaviorInstance class exist anymore? or am i just too confused now
[/edit1]
since i switched to 1.5 release my behaviors behave rather weird (some behavior methods can't be found, i did not yet check which exactly are broken, we have many nested behaviors...). my first guess is that it has something to do with getTemplateName() always returning null?
[edit1]
i just saw that BehaviorTemplate::createInstance returns a BehaviorTemplate instead of a BehaviorInstance. thats why calling getTemplateName on the returned object doesnt work...
doesnt the BehaviorInstance class exist anymore? or am i just too confused now
[/edit1]
#2
create some Behavior MyBehavior and call
this will return
but if you type in
you'll get
07/14/2007 (1:06 am)
Ok sorry i compared this to beta3 now and it was the same there, so this is not the reason for our misbehaving code. but here is what confused me:create some Behavior MyBehavior and call
$bla = MyBehavior.createInstance(); echo($bla.getTemplateName());
this will return
<input> (0): Unknown command getTemplateName. Object (2101) MyBehavior -> BehaviorTemplate -> SimObject
but if you type in
$bla.dumpClassHierarchy();
you'll get
BehaviorInstance -> SimObject ->
Associate Justin DuJardin
Default Studio Name
I think you're confused. the BehaviorTemplate class does return a BehaviorInstance when you call createInstance. Is there a documentation slip-up that's confusing you?
The new behaviors release is slightly more restrictive about how it recurses to call behaviors as to prevent people from entirely nuking themselves getting stuck in a recursive loop calling into owner, back into the behaviors, and into the owner, etc..
If you check out the behaviorComponent.cpp file in _callMethod you'll see some code-review comments that cover this. Snippet below
Hope this helps!
-Justin