Game Development Community

Stupid question about a SimObject

by Corin · in Torque Game Engine · 12/05/2005 (5:08 am) · 2 replies


#1
12/05/2005 (5:08 am)
Like this?

$foo = new SimObject() {
                x = 1;
                y = 2;
                z = 3;
           };

echo($foo.x + $foo.y + $foo.z);

But if you're gonna use it on scripts, I recommend using scriptObjects, not simObjects. ScriptObjects support the class and superClass fields, that allow you to link them to two namespaces. That way you could do this:

function vector::getLen(%this) 
{
    return mSqrt(%this.x*%this.x + %this.y*%this.y + %this.z*%this.z);
}

$foo = new ScriptObject() {
               class = vector;
           }

$foo.x = 10;
$foo.y = 10;
$foo.z = 10;

echo($foo.getLen());
#2
12/05/2005 (8:05 am)
You *can* do that, but BICI must be another object:

$foo = new SimObject();

$foo.BICI = new SimObject() {
    x = 1;                
    y = 2;                
    z = 3;   
};

echo($foo.BICI.x + $foo.BICI.y + $foo.BICI.z);

That'd work.

Ah, remember to add any new objects you create to MissionCleanUp. By default, when running a server, all objects are added to the missionGroup root (or whatever group is marked as root). And they'll be saved to your .MIS file if you save your mission, causing garbage. Just remember to do everytime:

$foo = new SimObject();
[b]MissionCleanUp.add($foo);[/b]