Page MenuHomeFeedback Tracker

CarController class is broken
Reviewed, UrgentPublic

Description

So, almost every "set" function in class CarController is not working

  • SetSteering
  • SetThrust

Only things that seems to be working are

  • ShiftUp/ShiftDown and ShiftTo

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General
Steps To Reproduce
HumanCommandVehicle vehCommand = GetGame().GetPlayer().GetCommand_Vehicle();
if ( vehCommand )
{
	Transport trans = vehCommand.GetTransport();
	if ( trans )
	{
		CarScript drivingVehicle;
		if ( Class.CastTo( drivingVehicle, trans ) )
		{
			CarController tctrl = drivingVehicle.GetController();
        		tctrl.SetSteering(0.5);
			tctrl.SetThrust(0.5, 0, 1);

			Print("GetThrust " + tctrl.GetThrust());
			Print("GetSteering " + tctrl.GetSteering());
		}
	}
}

Event Timeline

Unknown Object (User) created this task.Dec 7 2019, 2:25 PM
Geez changed the task status from New to Need More Info.Dec 9 2019, 4:04 PM
Geez added a subscriber: Geez.

Hello Camino.
Can you please describe what are you trying to achieve / what the code you have presented should do?
Regards,
Geez

Unknown Object (User) added a comment.Dec 21 2019, 7:09 PM

Hello, i am trying to force the vehicle to move forward and steer itself without driver

Geez added a comment.Jan 6 2020, 1:04 PM

Hello Camino.
The code you have provided should work. Is it possible that you are calling this code only on the client? As this should be called on the server in order for it to work correctly.
Regards,
Geez

Some more information to help solve this issue.

It's not working when called on a Server in MP either. Both with a human player (INSTANCETYPE_SERVER), an AI player (INSTANCETYPE_AI_SERVER) or no player in the seat.

Most likely not relevant but the AI was linked to the seat via Transport::CrewGetIn and Human::LinkToLocalSpaceOf, not from Human::StartCommand_Vehicle. Shouldn't be relevant because the two other scenarios did not work.

Best guess, the code is still updating the thrust and other variables just before the simulation starts overwriting the changes we make using the CarController.

An idea on how this could be solved is just to create and then expose a script method which is called after car inputs have been resolved in engine. This can then be used to override the inputs if a modder desires to do so.

SetSteering and SetThrust. Don't work dayz 1.08 27 July 2020

Tried both from server and client.

  1. Join the server with 1 player
  2. Get in the car with the 1 player
  3. run the following code
  4. SetSteering has no effect, no matter what values I use as the parameters

`

				Man t_Man;
				if (!t_Man) {
					array<Man> t_ArrMan = new array<Man>;
					GetGame().GetPlayers(t_ArrMan);
					if (t_ArrMan && t_ArrMan.Count() > 0) {
						t_Man = t_ArrMan.Get(0);
					};
				};
				if (!t_Man) {
					return;
				};
				Print("m:"+t_Man);
				PlayerBase t_Player = PlayerBase.Cast(t_Man);
				if (!t_Player) {return;};
				
				Car t_Car = Car.Cast(t_Player.GetCommand_Vehicle().GetTransport());
				CarController t_CC = Car.Cast(t_Player.GetCommand_Vehicle().GetTransport()).GetController();
				
				
				Print("t:" + t_Player.GetCommand_Vehicle());
				Print("t:" + t_Player.GetCommand_Vehicle().GetTransport());
				Print("t:" + Car.Cast(t_Player.GetCommand_Vehicle().GetTransport()).GetController());
				Print("t:" + Car.Cast(t_Player.GetCommand_Vehicle().GetTransport()).GetController().GetSteering());
				t_CC.SetThrust(0,0,0);
				t_CC.SetSteering(-1,false);	
				//t_CC.ShiftUp();

`

ShiftUp() worked as intended

komer added a subscriber: komer.May 15 2021, 11:29 AM

Please fix those methods above. In my usecase of bicycle I need set thrust when diver get in automatically to have more realistic entering to bicycle a instantly move. Right now is great that at leas gearbox controller is working, so I can automatically set gear to FIRST while entering to bicycle.

Geez changed the task status from Need More Info to Reviewed.May 5 2023, 11:05 AM

Hello everyone.
The original issue described in the report is solved for the next experimental update

New methods have been exposed within 'Car' to allow control of the car while there is no driver. This also extends to allowing non-player 'Human' based drivers, as long as the 'Human' entity is in 'HumanCommandScript' and not 'HumanCommandVehicle'.

As for the thing mentioned by @Hunterz that will not be solved with this update.