Download

AWheeledVehicle Stick Shift

Hi!

I want to add stick shift (manual transmission not semi-automatic) ability to my vehicle. From the documentation, looks like it is not possible in UE4 API. Simply thinking I can set the gear to N when clutch is pressed half way. But, when the gear is N and you press the throttle pedal the gear is automatically set to 1. Is there a way to disable this behavior? Or is there a way to develop a full manual transmission behavior with a clutch pedal?

Thanks!

After investigating the WheeledVehicleMovementComponent.cpp, found the following lines:

Lines: 829 - 840



//Manual shifting between reverse and first gear
if (FMath::Abs(GetForwardSpeed()) < WrongDirectionThreshold)	//we only shift between reverse and first if the car is slow enough. This isn't 100% correct since we really only care about engine speed, but good enough
{
	if (RawThrottleInput < 0.f && GetCurrentGear() >= 0 && GetTargetGear() >= 0)
	{
		SetTargetGear(-1, true);
	}
	else if (RawThrottleInput > 0.f && GetCurrentGear() <= 0 && GetTargetGear() <= 0)
	{
		SetTargetGear(1, true);
	}
}


I added GetUseAutoGears() inside the if statement and compiled the project, but nothing changed. I know it is not a good idea to change framework code, but it seems the only way. Another option would be to copy the contents to a new custom class. Which option do you think is better ?

Well struggled a while with inheriting AWheeledVehicle and UWheeledVehicleMovementComponent and somehow succeeded, but in my point of view, these classes are not suitable for inheritance. So, I decided to write my own vehicle classes.

Re-coding a custom vehicle with PhysX seems to be a very long process. The dependency goes from FPhysScene to UTireType, even AnimNode_WheelHandler.

In my code I need to override UpdateState method which is not virtual, so I also need to override PreTick method. The following code results in undeclared external symbol “FPhysXVehicleManager::VehicleSetupTag”. Declaring this in my cpp will solve compile problems but won’t relieve my pain!



	if (VehicleSetupTag != FPhysXVehicleManager::VehicleSetupTag)
	{
		RecreatePhysicsState();
	}


Looks like I can’t customize a UWheeledVehicleMovementComponent unless the FPhysXVehicleManager class is public.

I read from another post that the vehicle classes will be updated, but when? If not I think I’m going to change my engine.

Thanks!

Yay I did it. Thanks for no support :eek:

Could you please share how you got PhysXVehicleManager to work for you?

Congratulations!

You can’t. It is not accessible since it is private.

One easier way is to create a class which inherit from UWheeledVehicleMovementComponent4W and then override PreTick(void) for which you can tailor your own UpdateState. The lines

above are simply commented and therefore not needed (it has its uses in Editor mode, but can still be skipped).