Advertisement

OnClick doesn't Work

Started by February 14, 2022 04:20 PM
2 comments, last by hplus0603 2 years, 7 months ago

OnClickEvents used to work until I renamed my C++ class, I deleted the blueprint and made a new one now , it doesn't work and it rarely works when I spam clicks on it like 20 time for it to work once.

this is the event in the actor I am trying to click. Note I only use blueprint to set the mesh or transform and scale

	MeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComponent"));
	MyBoxComponent= CreateDefaultSubobject<UBoxComponent>(TEXT("MyBoxComponent"));
	SetRootComponent(MeshComponent);
	MyBoxComponent->SetupAttachment(MeshComponent);
	OnClicked.AddDynamic(this, &AMyClass::OnClick);

the player controller left mouse click is set to

	bShowMouseCursor = true;
	bEnableClickEvents = true;
	bEnableMouseOverEvents = true;

fido9dido said:

OnClickEvents used to work until I renamed my C++ class, I deleted the blueprint and made a new one now , it doesn't work and it rarely works when I spam clicks on it like 20 time for it to work once.

this is the event in the actor I am trying to click. Note I only use blueprint to set the mesh or transform and scale

	MeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComponent"));
	MyBoxComponent= CreateDefaultSubobject<UBoxComponent>(TEXT("MyBoxComponent"));
	SetRootComponent(MeshComponent);
	MyBoxComponent->SetupAttachment(MeshComponent);
	OnClicked.AddDynamic(this, &AMyClass::OnClick);

the player controller left mouse click is set to

	bShowMouseCursor = true;
	bEnableClickEvents = true;
	bEnableMouseOverEvents = true;

This sounds stupid but did you do a full clean build? Maybe it's still compiling/linking against old build files?

“It's a cruel and random world, but the chaos is all so beautiful.”
― Hiromu Arakawa

Advertisement

If it works “once” when spamming clicks “20 times” then you should probably look somewhere other than the code for the click.

Code is very deterministic. It always works, when the situation is the same. So, if it sometimes works, the situation is different when it doesn't.

For example – are you running client/server? Are you sometimes not receiving the pawn replicated yet when your player controller starts up?

enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement