Game Development Community

Newbie behavior questions

by Ken Lao · in Torque Game Builder · 01/08/2010 (3:59 am) · 2 replies

Hi! Just getting started with TGB and had a few questions.

1) Can I modify an existing behavior dynamically from a script? I see no way of getting a list of behaviors from a sceneobject, or docs on how to modify fields inside a behavior. e.g. if I use the "Move Toward" behavior from the BehaviorPlayground demo and want to change the "speed" field dynamically, can I do that?

2) I must be blind: are there reference docs on behaviors? I have found lots of forum threads on dynamically adding behaviors with myBehavior.createInstance() and %this.addBehavior(...), and I found tutorials etc., but I can't find any real docs on the TGB reference class hierarchy ( http://tdn.garagegames.com/wiki/TGB/Reference ) or anywhere else. e.g. I can't find any method called "addBehavior" in t2dSceneObject or SimObject, and I can't find any docs on Behaviors themselves (like, how do you all know there is .owner field that you can get the attached scene object from?)

Thanks!

#1
01/08/2010 (4:01 am)
1) yes, just change %handleOfTheBehavior.speed = xy;

2)As for addBehavior: it comes from the behavior side. If you check the t2dSceneObject.h you will see what t2dSceneObject really inherits from
#2
01/08/2010 (4:33 am)
Oh, weird - I didn't notice those docs before. Between the TDN and the tutorials and even the offical online TGB documentation, the only thing that had the actual complete info (on t2dSceneObject, behaviors, etc.) was the offline version of the TGB docs. Weird.

Thanks, that totally worked. whatever.getBehavior("MoveTowardBehavior").speed=xx;

I hate this part of getting into a new program, where you've got 50 browser tabs open and every line you write requires digging through page after page of docs and searching through forum posts :)