vehicle remote controlled?

There are no stupid questions, just stupid answers.
9 posts Page 1 of 1
subabrain
Posts: 136
Joined: Sat Aug 20, 2016 4:58 pm
 
by subabrain » Sun Feb 26, 2017 12:27 am
Hi there,

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

Thanks for answers :)

gn8
Robert
irei1as
Posts: 72
Joined: Fri Feb 27, 2015 5:13 pm
by irei1as » Sun Feb 26, 2017 11:40 am
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...)
subabrain
Posts: 136
Joined: Sat Aug 20, 2016 4:58 pm
 
by subabrain » Sun Feb 26, 2017 12:14 pm
@
User avatar
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
Johxz
Posts: 411
Joined: Sat Feb 07, 2015 11:37 pm
by Johxz » Sun Feb 26, 2017 5:00 pm
subabrain wrote: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
Image


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.
subabrain
Posts: 136
Joined: Sat Aug 20, 2016 4:58 pm
 
by subabrain » Sun Feb 26, 2017 5:43 pm
hi,

thanks a lot! Yes i will read it ;)

greetz
Robert
irei1as
Posts: 72
Joined: Fri Feb 27, 2015 5:13 pm
by irei1as » Mon Feb 27, 2017 8:41 am
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 );
subabrain
Posts: 136
Joined: Sat Aug 20, 2016 4:58 pm
 
by subabrain » Sat Jun 17, 2017 11:13 am
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
subabrain
Posts: 136
Joined: Sat Aug 20, 2016 4:58 pm
 
by subabrain » Sun Jun 18, 2017 3:08 pm
hi,

i got it:

localClientConnection.player

;)

greetings
Robert
Phantom139
Posts: 5
Joined: Tue Feb 10, 2015 12:23 am
 
by Phantom139 » Mon Jun 26, 2017 1:00 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.
9 posts Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest