### vehicle remote controlled?

There are no stupid questions, just stupid answers.

#### vehicle remote controlled?

subabrain
Posts: 190
Joined: Sat Aug 20, 2016 4:58 pm

Hi there,

i was thinking about to "remote control" a vehicle -> so can you control the vehicle from outside?

gn8
Robert

#### Re: vehicle remote controlled?

irei1as
Posts: 76
Joined: Fri Feb 27, 2015 5:13 pm
If the vehicle is a default one and you're ok with the default controls, the easiest way is to just set the vehicle as a control object (like you would like to control it from inside) but then change the camera to that outside one.

Something like:

Code: Select all

function GameConnection::controlOutVehicle(%this, %vehicle, %camera) { %camera.scopeToClient(%this); %this.setControlObject(%vehicle); %this.setFirstPerson(false); %this.setCameraObject(%camera); }
And then call if it's a single player game:
LocalClientConnection.controlOutVehicle(Vehicle_ID, Camera_ID);

(Vehicle_ID and Camera_ID are the id or name of the vehicle and the camera you created before.)

If it's multiplayer you can't use LocalClientConnection. You'll have to use the command to server and client and all that and use:
%client.controlOutVehicle(Vehicle_ID, Camera_ID);
(Note: tecnically, I should do it for single player, too...)

#### Re: vehicle remote controlled?

subabrain
Posts: 190
Joined: Sat Aug 20, 2016 4:58 pm

@
irei1as
- Thanks a lot!

but i dont know where i can find the vehicle and camera id?
i tried it in the wheeledVehicle file - but wheres the camera id?

Thanks a lot!

greetings
Robert

#### Re: vehicle remote controlled?

Johxz
Posts: 443
Joined: Sat Feb 07, 2015 11:37 pm
but i dont know where i can find the vehicle and camera id?
i tried it in the wheeledVehicle file - but wheres the camera id?
The easy way to see the ID

I would suggest to read the documentation subabrain...
https://github.com/John3/awesome-torque3d#tutorials
https://github.com/John3/awesome-torque3d#books

regards,
John
Last edited by Johxz on Sun Feb 26, 2017 6:02 pm, edited 1 time in total.

#### Re: vehicle remote controlled?

subabrain
Posts: 190
Joined: Sat Aug 20, 2016 4:58 pm

hi,

thanks a lot! Yes i will read it

greetz
Robert

#### Re: vehicle remote controlled?

irei1as
Posts: 76
Joined: Fri Feb 27, 2015 5:13 pm
Using the id is better if you're creating the objects on the run and saving their id as variables. Because id changes every time you run the game you can't just use the number.

If you have already created objects I think it's better to give them a global name (you can see that field just above the id box that Johxz pictured) and use that name (global name and number id are usually interchangeable in TorqueScript).
For example it would be like:

LocalClientConnection.controlOutVehicle( VehicleSteve , CameraJim );

#### Re: vehicle remote controlled?

subabrain
Posts: 190
Joined: Sat Aug 20, 2016 4:58 pm

Hi there,

sorry for the long delay ..

it works - but i dont get the object name of the player. Can you help me?

Thanks a lot!

Greetz
Robert

#### Re: vehicle remote controlled?

subabrain
Posts: 190
Joined: Sat Aug 20, 2016 4:58 pm

hi,

i got it:

localClientConnection.player

greetings
Robert

#### Re: vehicle remote controlled?

Phantom139
Posts: 7
Joined: Tue Feb 10, 2015 12:23 am

localClientConnection is a special object identifier you can use in a single-player environment (Where the server instance is the same as your game instance), beyond that, calling localClientConnection will access your ghost object instance, which will only affect things on your end of the simulation.

Personally, I'd avoid using that object for game logic altogether, as you can assume a persistent multiplayer environment, even in a singleplayer session and have your code be more "adaptable".

The challenge you'll be looking at is what was mentioned above, game object identifiers change with each session and are non-constant, therefore you'll need to have a variable instance. The way I'd approach the problem here is to define a function instance that takes the client object and the vehicle object in question, ala:

Code: Select all

function GameConnection::controlVehicle(%this, %vehicleObject) { %this.setControlObject(%vehicleObject); //Add other code here... } 
From there, you'll just need to figure out which client is doing the interaction here. If you're using a keystroke to handle this interaction, then the server/client interactions can pick up the client identifier. You can also grab a list of client objects by looping over the ClientGroup object instance on the server.

#### Who is online

Users browsing this forum: No registered users and 1 guest