subabrain Posted February 25, 2017 Share Posted February 25, 2017 Hi there,i was thinking about to "remote control" a vehicle -> so can you control the vehicle from outside?Thanks for answers :)gn8Robert Quote Link to comment Share on other sites More sharing options...
irei1as Posted February 26, 2017 Share Posted February 26, 2017 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...) Quote Link to comment Share on other sites More sharing options...
subabrain Posted February 26, 2017 Author Share Posted February 26, 2017 @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!greetingsRobert Quote Link to comment Share on other sites More sharing options...
Johxz Posted February 26, 2017 Share Posted February 26, 2017 (edited) 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 IDhttp://i.imgur.com/VlSp7AS.pngI would suggest to read the documentation subabrain... https://github.com/John3/awesome-torque3d#tutorialshttps://github.com/John3/awesome-torque3d#booksregards,John Edited February 26, 2017 by Johxz Quote Link to comment Share on other sites More sharing options...
subabrain Posted February 26, 2017 Author Share Posted February 26, 2017 hi,thanks a lot! Yes i will read it ;)greetzRobert Quote Link to comment Share on other sites More sharing options...
irei1as Posted February 27, 2017 Share Posted February 27, 2017 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 ); Quote Link to comment Share on other sites More sharing options...
subabrain Posted June 17, 2017 Author Share Posted June 17, 2017 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!GreetzRobert Quote Link to comment Share on other sites More sharing options...
subabrain Posted June 18, 2017 Author Share Posted June 18, 2017 hi,i got it:localClientConnection.player;)greetingsRobert Quote Link to comment Share on other sites More sharing options...
Phantom139 Posted June 25, 2017 Share Posted June 25, 2017 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.