Game Development Community

can i use setControlObject() in any client side function?

by Ahsan Muzaheed · in Torque 3D Beginner · 04/15/2012 (7:58 pm) · 2 replies

i was trying this:

function clientCmdchangecamera(%client,%obj)
{
    %client.camera.setTrackObject(%obj,VectorSub(%obj.getTransform(),("-10 -5 -5 -1")));//%obj.getTransform(),("0 5 500 1"))
    %client.camera.setVelocity("1000 1000 1000");
    %client.setControlObject(%client.camera);
    clientCmdSyncEditorGui();//?????????????????????????
    
}

in host side client it works fine.
but in other client it shows:

Unable to find object: '' attempting to call function 'setTrackObject'
'4326' attempting to call function 'setControlObject'


i think access to camera in client side is not possible.
am i right?



//*************************//
although i have done this by another command:
game.changecamera(%sourceClient,%obj);

function GameCore::changecamera(%game, %client,%obj)
{
    %client.camera.setTrackObject(%obj,VectorSub(%obj.getTransform(),("-10 -5 -5 -1")));//%obj.getTransform(),("0 5 500 1"))
    %client.camera.setVelocity("1000 1000 1000");////////////
    %client.setControlObject(%client.camera);/////////////

}

but a client side function and a command to that function(instead of those 3 line of code) in changeCamera() can save some network data.
that is why i was trying to make a client side function.

About the author

Torque 3D enthusiastic since 2010.Have been working in several T3D projects besides of Unreal Engine 4 and Unity 3D. NEED a hand with your project? SHoot me a mail. http://www.garagegames.com/community/forums /viewthread/138437/


#1
04/16/2012 (7:35 am)
you can use 'ServerConnection'.

below client-side sample code.
function test()
{
   %obj = ServerConnection.getControlObject();
   echo( "%obj Position = " @ %obj.getTransform() );
}
#2
04/21/2012 (10:55 am)
or, from your command to client, make a serverCmd and then use setControlObject

function serverCmdControlObj(%client,%obj) {
   %client.setControlObject(%obj);
}

%client is auto-defined, no parameters necessary for it to be sent to the server.