UnrealScripterAI
Discord ↗
Link Copied to Clipboard
×
"make light switch trigger when user enters sphere"
ALightSwitchTrigger::ALightSwitchTrigger() { // 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; LightIntensity = 3000.0f; PointLight = CreateDefaultSubobject<UPointLightComponent>(TEXT("Point Light")); PointLight->Intensity = LightIntensity; PointLight->bVisible = true; RootComponent = PointLight; LightSphere = CreateDefaultSubobject<USphereComponent>(TEXT("Light Sphere Component")); LightSphere->InitSphereRadius(300.0f); LightSphere->SetCollisionProfileName(TEXT("Trigger")); LightSphere->SetupAttachment(RootComponent); LightSphere->OnComponentBeginOverlap.AddDynamic(this, &ALightSwitchTrigger::OnOverlapBegin); LightSphere->OnComponentEndOverlap.AddDynamic(this, &ALightSwitchTrigger::OnOverlapEnd); }