Pawn can't move after collision change to BlockAll

Hi, I changed the capsule component collision type to Block All, then the tank cannot move in the scene.
It just sticks to the start location.
Then I turn it back to Overlap all dynamic, unreal crashed.

Anyone has the same problem? I don’t know how to debug or solve it. Any thoughts?

I also wonder if Unreal has a version control or something that can let me return to a version saved previously before crash.

Crash report:
Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x00000000

UE4Editor_ToonTanks!APlayerControllerBase::SetPlayerEnabledState() [C:…\PlayerControllerBase.cpp:9]
UE4Editor_ToonTanks!ATankGameModeBase::HandleGameStart() [C:…\TankGameModeBase.cpp:52]

if(PlayerControllerRef)
    {
        PlayerControllerRef->SetPlayerEnabledState(false);

        FTimerHandle PlayerEnableHandle;
        FTimerDelegate PlayerEnableDelegate = FTimerDelegate::CreateUObject(PlayerControllerRef, 
            &APlayerControllerBase::SetPlayerEnabledState, true);
        GetWorld()->GetTimerManager().SetTimer(PlayerEnableHandle, PlayerEnableDelegate, StartDelay, false);
    }

Line 52 is FTimerHandle PlayerEnableHandle;

It seems it is very random. I tried changing the playerController in GameBase from BP_PlayerController to the original playerController and play. And then change it back to the BP_PlayerController, it didn’t crash. Then I tried change the collision type of the Tank capsule component, and play. Sometimes it crashed sometimes not…
Failed to find out the reason …

Could you show your player controller?

You mean the code?


#pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "PlayerControllerBase.generated.h"

UCLASS()
class TOONTANKS_API APlayerControllerBase : public APlayerController
{
	GENERATED_BODY()

public:
	void SetPlayerEnabledState(bool SetPlayerEnabled);
	
};


#include "PlayerControllerBase.h"


void APlayerControllerBase::SetPlayerEnabledState(bool SetPlayerEnabled) 
{
    if (SetPlayerEnabled)
    {
        GetPawn()->EnableInput(this);
    }
    else
    {
        GetPawn()->DisableInput(this);
    }

    bShowMouseCursor = SetPlayerEnabled;
    
}

Is the crash report the same? If not could you post it?

yes the crash is report is the same.

Could you send your project?

https://drive.google.com/file/d/1hzNRLyHT6RkGpcoA_bTBL3lyjrOOlqXR/view?usp=sharing

Here is the link to the project.

It seems it is not spawning my Pawn Tank when I hit play. I failed to find out the reason.

Thank you for your help!

Your pawn failed to spawn due to the BaseMesh using BlockAll instead of BlockAllDynamic this meant

GetPawn()->EnableInput

Was dereferencing a null pointer.

Setting the BaseMesh to BlockAllDynamic can avoid the crash but the tank now goes through the wall.
In ToonTanks course (No. 164), the BaseMesh is set to BlockAll and no crash.
What should I do to avoid the crash and make the tank no go through the wall?

On further inspection it’s because your capsule component is OverlapAllDynamic instead of BlockAll.

Thank you so much for your help! The BlockAll should be set to CapsuleComp instead of BaseMesh…
Could you please explain a bit why using BlockAll on the BaseMesh will cause the GetPawn()->EnbaleInput to deref a null pointer?

Rob has it set on both.

Already stated. The pawn failed to spawn. If you add a if statements to check if GetPawn returns nullptr so you don’t deref a null pointer you should see it messages in the output log that it failed to spawn.

Why the BlockAll on the base mesh will cause the pawn fail to spawn? (sorry for asking so many questions…

OverlapAllDynamic on capsule + BlockAll on mesh causes the issue.

And to be honest I’m not entirely sure. Would have thought it was the other way round (BlockAll on both) that would cause the problem spawning as it doesn’t spawn if there’s something blocking it from doing so.

Thank you so much for your big help! :smiley: