how to set a behavior field at run time !?
by ken · in iTorque 2D · 05/19/2012 (7:00 am) · 5 replies
for example i create a behavior like this :
if (!isObject(testbhr))
{
%template = new BehaviorTemplate(testbhr);
%template.friendlyName = "test behavior";
%template.behaviorType = "testing";
%template.description = "for test";
%template.addBehaviorField("testbhrField","test behavior field",float,"3");
}
then add it to a object in the scene
after all these i want to change the value of behavior field "testbhrField" to something like "2" in a function,
how can i do that !?
thanks !
if (!isObject(testbhr))
{
%template = new BehaviorTemplate(testbhr);
%template.friendlyName = "test behavior";
%template.behaviorType = "testing";
%template.description = "for test";
%template.addBehaviorField("testbhrField","test behavior field",float,"3");
}
then add it to a object in the scene
after all these i want to change the value of behavior field "testbhrField" to something like "2" in a function,
how can i do that !?
thanks !
#2
05/19/2012 (8:56 am)
no , i mean a console function, not a behavior method !
#3
05/19/2012 (9:20 am)
@ken - Can you explain a little more. You want to write a ConsoleFunction in C++ to access the behavior field?
#4
05/19/2012 (9:54 am)
yes, if needed !
#5
05/20/2012 (4:07 pm)
@ken - You need to know the object that has the behavior. For example, let's say you have something called $player. You attached a behavior to it by the name of "ExampleBehavior". This has a field in it called myField.$player.getBehavior("ExampleBehavior").myField = ???;
Torque Owner John Vanderbeck
VanderGames
So for example if you are in a method for your behavior, you can access it via %this.testbhrField