Member is inaccessible

I am following along with the documentation here: CPP Only Example | Unreal Engine 5.4 Documentation | Epic Developer Community

I am getting the following error: Member is inaccessible

The relevant line of code is PointLight1->bVisible = true;

PointLight1 = CreateDefaultSubobject<UPointLightComponent>(TEXT("PointLight1"));
	PointLight1->Intensity = DesiredIntensity;
	PointLight1->bVisible = true;

I don’t have the code in front of me to check, however, I suspect the bVisible member variable is Protected. They likely have a set method like SetVisibility.

EDIT:

I just dug through the class reference for a scenecomponent and found the following

In your case, to recreate what the example is doing, you want PointLight1->SetVisibleFlag(true);

Clearly the example needs to be updated to reflect changes to the baseline implementation.

1 Like

That you @gh0stfase1 my code now works :slight_smile: Hopefully they will update it.

There is a fair bit in the code example from that page that is never explained. Why does my function need 6 parameters when I only actually use two of them?

void ALightSwitchCodeOnly::OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
	if (OtherActor && (OtherActor != this) && OtherComp)
	{
		ToggleLight();
	}
}

It’s because you are overriding a base class method (function). This method is already declared in some class you have inherited from. In order to override it, you have to match its argument list whether you use the arguments or not.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.