Crash When I Change C++ Variable

#include "PlayerCharacter.h"
#include "Kismet/GameplayStatics.h"
// Sets default values
APlayerCharacter::APlayerCharacter()
{
 	// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

}

// Called when the game starts or when spawned
void APlayerCharacter::BeginPlay()
{
	Super::BeginPlay();
	
}

// Called every frame
void APlayerCharacter::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}

// Called to bind functionality to input
void APlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
	Super::SetupPlayerInputComponent(PlayerInputComponent);
	// Keyboard Aim
	PlayerInputComponent->BindAction(TEXT("Aim"), EInputEvent::IE_Pressed, this, &APlayerCharacter::Aim);
	PlayerInputComponent->BindAction(TEXT("Aim"), EInputEvent::IE_Released, this, &APlayerCharacter::Idle);

}

void APlayerCharacter::Aim()
{
	IsAiming = true;
}
void APlayerCharacter::Idle()
{
	IsAiming = false;
}

When I change the variable ‘IsAiming’ through the right mouse button, UE5 crash.
I don’t guess why. How can I fix it?

Are your Aim() and Idle() marked as UFUNCTION() ?

Generally if not, you’d get some error, but no crash, but it’s still worth checking.

1 Like

I solved it! UFUNCTION(BlueprintCallable) is the key!
Thank you so much!