Hey all,
I am doing an Unreal project for school, but I am having trouble getting it to work properly. I have tried looking it up online to solve the problem myself, which for the most part I did, but I am still getting an inaccessible error for bVisible and I cannot figure out why.
.cpp code
// Fill out your copyright notice in the Description page of Project Settings.
#include "J_Ercolano_GAM312.h"
#include "LightSwitchCodeOnly.h"
#include "Components/PointLightComponent.h"
#include "Components/SphereComponent.h"
#include "DrawDebugHelpers.h"
// Sets default values
ALightSwitchCodeOnly::ALightSwitchCodeOnly()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
DesiredIntensity = 3000.0f;
PointLight1 = CreateDefaultSubobject<UPointLightComponent>(TEXT("PointLight1"));
PointLight1->Intensity = DesiredIntensity;
PointLight1->bVisible = true;
RootComponent = PointLight1;
Sphere1 = CreateDefaultSubobject<USphereComponent>(TEXT("Sphere1"));
Sphere1->InitSphereRadius(250.0f);
Sphere1->SetCollisionProfileName(TEXT("Trigger"));
Sphere1->SetupAttachment(RootComponent);
Sphere1->OnComponentBeginOverlap.AddDynamic(this, &ALightSwitchCodeOnly::OnOverlapBegin); // set up a notification for when this component overlaps something
Sphere1->OnComponentEndOverlap.AddDynamic(this, &ALightSwitchCodeOnly::OnOverlapEnd); // set up a notification for when this component overlaps something
}
// Called when the game starts or when spawned
void ALightSwitchCodeOnly::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ALightSwitchCodeOnly::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void ALightSwitchCodeOnly::OnOverlapBegin(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
if (OtherActor && (OtherActor != this) && OtherComp)
{
ToggleLight();
}
}
void ALightSwitchCodeOnly::OnOverlapEnd(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
if (OtherActor && (OtherActor != this) && OtherComp)
{
ToggleLight();
}
}
void ALightSwitchCodeOnly::ToggleLight()
{
}
.h code
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "LightSwitchCodeOnly.generated.h"
UCLASS()
class J_ERCOLANO_GAM312_API ALightSwitchCodeOnly : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ALightSwitchCodeOnly();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
//point light component
UPROPERTY(VisibleAnywhere, Category = "Switch Components")
class UPointLightComponent* PointLight1;
//sphere component
UPROPERTY(VisibleAnywhere, Category = "Switch Components")
class USphereComponent* Sphere1;
// called when something enters the sphere component
UFUNCTION()
void OnOverlapBegin(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
// called when something leaves the sphere component
UFUNCTION()
void OnOverlapEnd(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
// Toggles the light component's visibility
UFUNCTION()
void ToggleLight();
//the desired intensity for the light
UPROPERTY(VisibleAnywhere, Category = "Switch Variables")
float DesiredIntensity;
};
I cannot for the life of me figure this out. The error reads âmember âUSceneComponent::bVisibleâ (declared at line 199 of [bunch of locations]SceneComponent.hâ) is inaccessibleâ. I went to the Scene Component and it doesnât want me to edit anything without prompting me about what I am doing. I have been trying to fix the problem for a while now and I am getting nowhere. It would be nice to hear exactly what this is because I donât know that. Thanks a million for the help!