I have 2 PlayerController classes: PlayerController2 extends PlayerController1.
PlayerController1 have protected variable someclass* myclass;
PlayerController1 have PostInitializeComponents() where i set myclass = spawn()…
PlayerController2 have no overriding of PostInitializeComponents(); so then PostInitializeComponents() is executed in parent class - in PlayerController1.
PlayerController2 is spawned and active. When it was spawned, then PostInitializeComponents() was executed in parent class PlayerController1 and myclass was initialized with spawned object.
But when later i try to use myclass variable in code PlayerController2 then it is NULL.
Same thing with SetupInputComponent()
SetupInputComponent() function is overrode in both classes. Also both classes are calling Super::SetupInputComponent();
But actions binded in parent class have null variables when it was called.
For example InputComponent->BindAxis(“MoveForward”, this, &ATestPlayerController1::MoveForward);
function MoveForward called every frame, but all variables there are null, even all of them was initialized in subclass.
I do not understand why, i believed that all variables initialized in parent should be valid in subclass, ans variables defined in parent class then initialized in subclass and then used in parent class should also be valid.
What is wrong with my thoughts?