What parameters did you use for your friction?

Why not share your parameters here. Maybe share a GIF or short video of your tanks not sliding!

Hello Ben,

Can you explain why protecting GetPawn() can solve the blueprint hard crash problem?

Hi there, you’re stretching my memory and yes I’ll try. By the way you can use code formatting here if you wish to make code stand-out, e.g. GetPawn()

I have reviewed this video and I think I explain this fairly carefully near the start of the video. The underlying issue is if we’re not possessing a tank, the GetPawn() will return a null pointer.

I’d be interested to hear if, after a few more videos, this makes sense for you in context?

scratch that.

Thank you Ben for your reply.

But what I don’t understand is that:
The crash happens to TankPlayerController blueprint, what does tank not being possessed to do with it?

I’m confused because inside the controller blueprint, it does not use or reference to the possessed tank. Plus the blueprint crashes even if the game runs properly (which means the tank IS possessed).

Another factor that confuses me is that the event, the blueprint calls ,FoundAimingComponent is broadcasted on the BeginPlay, how come a pointer protection in AimTowardsCrosshair can solve the crash problem?

Hi Zhaoyang,

This crash happens because when you open TankPlayerController in the blueprint editor, an instance is spawned/instantiated. As this class has a Tick method, these start to fire immediately and begin calling AimTowardsCrosshair(). At that moment, there is no pawn, and so the call to GetPawn() returns nullptr, which can not be dereferenced ( GetPawn()->FindComponent… becomes NULL->FindComponent… and causes a segmentation fault ).

Similarly when you eject while playing, this causes you to de-possess the tank ( there are other scenarios Ben describes in that video as I recall, such as dying … where you would want to de-possess to cut off input from a dead player … as an example).

This protection prevents crashing by avoiding a bad dereference in all scenarios where a pawn might be missing.

I hope this clears it up for you!

Edit: If you add the below UE_LOG and compile, and wire up the BP per the screenshot ( which are effectively doing the same thing ), you will see that in your level WITHOUT PLAYING, the results in the output log. This indicates clearly the BP is being instantiated in the editor and is not tied to playing. Pawns however are not spawned unless playing.

Output Log:
LogTemp:Warning: AIMTICK
LogBlueprintUserMessages: [TankPlayerController_BP_C_26] 2552.5896TICKING
LogTemp:Warning: AIMTICK
LogBlueprintUserMessages: [TankPlayerController_BP_C_26] 2552.600342TICKING
LogTemp:Warning: AIMTICK
LogBlueprintUserMessages: [TankPlayerController_BP_C_26] 2552.614258TICKING
LogTemp:Warning: AIMTICK

Changes:

void ATankPlayerController::AimTowardsCrosshair()
{

    UE_LOG(LogTemp, Warning, TEXT("AIMTICK"));
    // depossessing will cause pawn to be missing ergo crashing in pie
    if ( !GetPawn() ) { return; }

1 Like

Privacy & Terms