Game Development Community

Player and Vehicle controls overriding each other

by Britt Scott · in Torque 3D Professional · 10/22/2012 (12:03 am) · 13 replies

First off, I'm using T3D open source, windows 7, and an Xbox 360 controller.

Hope, I can explain this!

Using the xbox controller to run straight into a vehicle, the vehicle keeps moving forward. This occurs even if the analog sticks are in the "neutral" position. The vehicle can be stopped by using the "handbrake", but will continue moving again after release.

When exiting the vehicle, the player will start traveling the same direction as when they entered the vehicle for a short distance. In some cases, upon vehicle exit, the player uses the vehicle controls for movement.

I tested it on both the "Cheetah" and "buggy". I have no vehicle/player control issues when using a mouse and keyboard.

Is there a way to make sure vehicles and players are only using their specific actionMaps?

About the author

Attended Brown College in Mendota Heights, MN for Game Design and Development. Projects include the Mech Starter Kit and the Battle Frog. Currently working toward a game design career.


#1
10/22/2012 (2:15 am)
Unless you've modified the action maps, I'm pretty sure player and vehicle controls use the same map. I'd suggest looking through default.bind to see if the gamepad controls are being handled differently.
#2
10/22/2012 (9:03 am)
Currently player is using moveMap and vehicle is using vehicleMap. As far as I know, action maps should be original based on the download.
#3
10/23/2012 (5:20 am)
Are you pushing and poping you maps correctly?
#4
10/23/2012 (5:22 am)
you can also look through this where you don't have to push and pop action maps you could just wrap your controls into a package and switch packages when needed.

RPG Resource 5 AKA Classic Battle/ AI / package system
#5
10/23/2012 (8:48 am)
As Kevin has stated I think you need to be pushing the correct maps each time you enter/exit a vehicle:

Something like this would work: (do note I don't know the exact function for vehicle mount/unmount, just look them up)
function VehicleData::OnMount(%this, %obj, %slot) {
   commandToClient(%obj.getMountedObject(%slot).client, 'pushVehicleMap');
}

function VehicleData::OnUnMount(%this, %obj, %slot) {
   commandToClient(%obj.getMountedObject(%slot).client, 'popVehicleMap');
}

then add the following code to the client:
function clientCmdPushVehicleMap() {
   MoveMap.pop();
   VehicleMap.push();
}

function clientCmdPopVehicleMap() {
   VehicleMap.pop();
   MoveMap.push();
}

Hope that helps!
#6
10/23/2012 (10:18 am)
Code is already there?

server/player.cs - onMount
if(%obj.getClassName() $= "Player")
         commandToClient(%obj.client, 'toggleVehicleMap', true);

client/client.cs
function clientCmdtoggleVehicleMap(%toggle)
{
   if(%toggle)
   {
      moveMap.pop();
      vehicleMap.push();
   }
   else
   {
      vehicleMap.pop();
      moveMap.push();
   }
}

I just wonder if it's the gamepad messing things up. Would it be wise to make new actionMaps for just the gamepad?
#7
10/23/2012 (11:02 am)
I don't know how extensively the gamepad support has been tested. It is possible that a previous action is not being cleared (break not being issued) when switching action maps. Is everything working as expected when using the keyboard and mouse?

- Dave
#8
10/23/2012 (11:18 am)
I have no problems, using the keyboard and mouse.
#9
10/23/2012 (1:00 pm)
I recall some issue involving a gamepad in which movement was constant when the game started up until some other key was pressed. I don't remember the solution and my search-fu isn't so good at finding that thread... but I think Dave is pointing in the right direction in regards to some action not being cleared when switching action maps.
#10
10/23/2012 (3:53 pm)
I've been using the controller fully with no issues yet. What issues have you had?
#11
10/23/2012 (10:52 pm)
@Kevin, my issues are at the top. If I need to explain further, let me know. I still need to give your resource a try too.

@Michael, I'll give the engine code a closer look.
#12
10/23/2012 (11:31 pm)
Britt
The map 'toggleVehicleMap' is usually on the keyboard only. You can add to the map and the functions of the selection key movements of gamepad.
I think your problem will be solved in this way.
#13
10/25/2012 (12:06 pm)
Ended up doing this to stop my runaway Cheetah:

client/client.cs

function clientCmdtoggleVehicleMap(%toggle)
{
   if(%toggle)
   {
	$mvForwardAction = 0;//Gamepad vehicle stop		BrittEdit
	$mvBackwardAction = 0;//Gamepad vehicle stop	BrittEdit
      moveMap.pop();
      vehicleMap.push();
   }
   else
   {
      vehicleMap.pop();
      moveMap.push();
   }
}