Jump to content

vehicle remote controlled?


subabrain
 Share

Recommended Posts

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:

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...)

Link to comment
Share on other sites

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

http://i.imgur.com/VlSp7AS.png



I would suggest to read the documentation subabrain...

https://github.com/John3/awesome-torque3d#tutorials

https://github.com/John3/awesome-torque3d#books


regards,

John

Edited by Johxz
Link to comment
Share on other sites

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 );

Link to comment
Share on other sites

  • 3 months later...

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:

 

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...