Game Development Community

AddBehaviorTemplate

by Jumex · in Torque Developer Network · 07/18/2007 (5:22 am) · 1 replies

Over the last few days I have been woking with the 2D engine's behavior scripts. I have them almost figured out exept for a particular aspect.


%template.addBehaviorField(speed, "The speed to move toward the object at (world units per second)", float, 2.0);

%template.addBehaviorField(damage, "The amount of damage to apply", int, 10);


These are just 2 examples of the ".addBehaviorField" being used. Now my theory is that "SPEED" and "DAMAGE" are already defined in the engine. If this is the case where do I find a list of all these parameters that can be used with the ".addBehaviorField"

#1
07/18/2007 (8:02 am)
--Note: this question would be much better if posted in the TGB forum sections. The forum section you used (Torque Developer Network >> General Discussion) has nothing to do with TGB.


No, those fields are not already defined in the engine at all. addBehaviorField() does a couple of things:

--creates a new dynamic field (by definition, not implemented within the engine, only for TorqueScript use) for your bahavior.
--gives the Level Builder information on how to allow level builder users to modify your dynamic field.

You can create any dynamic fields you wish with addBehaviorField, and they will be available within the level builder for GUI based editing. You must use these fields within TorqueScript (commonly in the various Behavior callbacks that are supplied by the engine) to affect the actions of the "owner" of this instantiation of the behavior.