Vehicle : moving with keyboard and looking with mouse
by Pat AfterMoon · in Torque Game Engine · 08/02/2004 (2:33 pm) · 4 replies
This question is primary related to the Mike Stoddart Torque Vehicle Resource, but can probably be answered in a "ActionMap" and "setControlObject" point of view.
With this resource, your player can mount a vehicle with multiple seat.
The seat 0 is for the driver, and input keyboard are redirected to the vehicle object (arrow keys turn the vehicle, go forward or backward, and the mouse turn too).
The seat 1 and next are for passenger and input keyborad are directed to the player object (arrow key and mouse let you look at every direction).
What I want to do is a mix of these 2 management : arrow key for piloting the vehicle and mouse for freelook, at the same time.
Here is the piece of code that (if I understand well) redirect input depending of your seat position
(server/scripts/vehicle.cs -> function setActiveSeat)
How can I do what I want ?
Must I recall setControlObject on the fly depending each input ?
In other words, I want a vehicle with a gunner that can look in all direction and drive the vehicle at the same time.
With this resource, your player can mount a vehicle with multiple seat.
The seat 0 is for the driver, and input keyboard are redirected to the vehicle object (arrow keys turn the vehicle, go forward or backward, and the mouse turn too).
The seat 1 and next are for passenger and input keyborad are directed to the player object (arrow key and mouse let you look at every direction).
What I want to do is a mix of these 2 management : arrow key for piloting the vehicle and mouse for freelook, at the same time.
Here is the piece of code that (if I understand well) redirect input depending of your seat position
(server/scripts/vehicle.cs -> function setActiveSeat)
// Are we driving this vehicle?
if (%seat == 0)
%client.setControlObject(%vehicle);
else
%client.setControlObject(%client);How can I do what I want ?
Must I recall setControlObject on the fly depending each input ?
In other words, I want a vehicle with a gunner that can look in all direction and drive the vehicle at the same time.
#2
But, about the feature I want to implement, the question is open.
The setControlObject let me thinking that all control command are directed to a single object. It can be the player the vehicle, ...
So, how can I send a command directly to an object. I want to control multiple object at the same time (the vehicle and the mounted player ).
The global variables $mvForwardAction and $mvLeftAction are modified by the script when you move forward or turn left, and they seem to be applied to the controled object by the engine. Is it possible from script to explicitly send an action to an object. I think about something like :
Can the feature I want be implemented by script (I hope) or must I modify the engine ?
08/03/2004 (2:07 pm)
Quote:You can't use %client.setControlObject(%client)Ben, I understand your message. I have looked at the vehicle code of the resource, and the function setActiveSeat is called with the %client.player variable :
function setActiveSeat(%client, %vehicle, %vehicleblock, %seat) : setActiveSeat(%client.player, %client.player.mvehicle, %client.player.mvehicle.getDataBlock(), %newSeat);The setActiveSeat parameters terminology could maybe be better ;)
But, about the feature I want to implement, the question is open.
The setControlObject let me thinking that all control command are directed to a single object. It can be the player the vehicle, ...
So, how can I send a command directly to an object. I want to control multiple object at the same time (the vehicle and the mounted player ).
The global variables $mvForwardAction and $mvLeftAction are modified by the script when you move forward or turn left, and they seem to be applied to the controled object by the engine. Is it possible from script to explicitly send an action to an object. I think about something like :
%client.player.ExecuteAction(moveleft) : %client.player.mvehicle.ExecuteAction(moveleft)
Can the feature I want be implemented by script (I hope) or must I modify the engine ?
#3
08/05/2004 (8:00 am)
I know there is a "free-look" mode you can activate by holding down a key normally. This lets you rotate the camera around the control object instead of actually turning it. If all you need is the camera view, I'm sure there is a way to lock this mode when you are in the vehicle.
#4
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5345 and it seem to contain a lot of interesting stuff near what I want (the readme talk about a turret mounted on a vehicle where the player can be the driver and the gunner at the same time).
08/05/2004 (1:21 pm)
Paul, I haven't found any key that allow a freelook when driving a vehicle. But I'm currently playing with the turret ressource :www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5345 and it seem to contain a lot of interesting stuff near what I want (the readme talk about a turret mounted on a vehicle where the player can be the driver and the gunner at the same time).
Associate Kyle Carter