Dynamic Behavior Fields?
by Joshua Hogsett · in Torque Game Builder · 09/14/2011 (10:03 am) · 1 replies
I've been struggling to find much in-depth documentation on behaviors, but have been able to get by with some things found in the forums and looking over some of the behavior tutorials. What I'm planning on doing is essentially create a behavior engine in TGB, so when our game starts going into production, there will be very little need for much extra scripting because all of the objects in the game have their behaviors that control everything they do. In order to achieve this, I need to really understand and master the use of behaviors.
One thing I wanted to look into is if it's possible to have... say a bool behavior field that, when checked, will display another behavior field. For example, I have a behavior that controls the motion of it's owner and has 2 behavior fields, float speed, and bool rotateWhileMoving. I want to add a couple of behavior fields when rotateWhileMoving is checked, like float rotateSpeed and enum rotationType (this would be a list of ways that the object might rotate, like "Change Direction", or "Isometric Animation").
Any insight on this subject would be very much appreciated, whether it be an answer to this specific question, or being pointed in the direction of some better documentation for working with behaviors.
One thing I wanted to look into is if it's possible to have... say a bool behavior field that, when checked, will display another behavior field. For example, I have a behavior that controls the motion of it's owner and has 2 behavior fields, float speed, and bool rotateWhileMoving. I want to add a couple of behavior fields when rotateWhileMoving is checked, like float rotateSpeed and enum rotationType (this would be a list of ways that the object might rotate, like "Change Direction", or "Isometric Animation").
Any insight on this subject would be very much appreciated, whether it be an answer to this specific question, or being pointed in the direction of some better documentation for working with behaviors.
Employee Michael Perry
ZombieShortbus
The script files for the editor are all found in the tools directory. You can easily browse them via Torsion, which is in the Torsion directory. The original developers made a lot of helper functions that dynamically create and hide fields. You'll notice a standard static sprite's properties contain the functionality you are looking for. Check out the Blending section in the properties for an object (from the editor). When activate and deactivate the blending checkbox, more fields show up.
That kind of logic is handled across four or five different functions. To sum up, it is possible to do. However there is not specific documentation on extending the editor. It will take a decent chunk of time, but there are scripts dedicated to the behavior editor. You would just need to copy some code from the other editors.