The control of the pawn is blocked without the possess function

I installed a ready-made template Vehicle advanced c++. After that i write some code on c++ in tick event(or a write on bluprints - the problem remains on blueprint as well) that GetVehicleMovementComponent()->SetThrottleInput(1.0); for example. But this action is not applied until you call the function possess from player controller.
What switches when possess function is called. And how fix this problem? I need the ability to control the pawn from the code (explicitly specifying the inputs for movement component) and I need the ability to call the possession function to, for example, look at the events on the map from the pawn camera.
I find this one in source code of example.

I have solved this problem. To solve this problem, you need to go to the file \Engine\Plugins\Runtime\PhysXVehicles\Source\PhysXVehicles\Private\WheeledVehicleMovementComponent.cpp
after that uou need to go to void UWheeledVehicleMovementComponent::UpdateState( float DeltaTime )
and you need to remove the check for belonging to the controller:
// update input values
AController* Controller = GetController();

// TODO: IsLocallyControlled will fail if the owner is unpossessed (i.e. Controller == nullptr);
// Should we remove input instead of relying on replicated state in that case?
if (Controller && Controller->IsLocalController())
{...} else{}

after that you need to recomlpile plugin PhysXVehicles or you can recompile all unreal engine code( on youtuube you can find tutorials - I found them there). I didn’t try to recompile the plugin, but I tried the whole project. it worked.

note. After everything worked - and it could not fail to work because I watched the inclusions by header files. I found another file that has the same check, however, it is not included in the code, so it does not introduce a problem, however, it can happen to you, so do the same in the file
Engine\Plugins\Experimental\ChaosVehiclesPlugin\Source\ChaosVehicles\Private\ChaosVehicleMovementComponent.cpp

1 Like