Unfortunately, going through the very first C++ bits in the docs, I’m encountering something I don’t understand.
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#include "BasicClasses.h"
#include "LightSwitchBoth.h"
ALightSwitchBoth::ALightSwitchBoth(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP) {
DesiredBrightness = 15.0f;
PointLight1 = PCIP.CreateDefaultSubobject<UPointLightComponent>(this, "PointLight1");
PointLight1->Brightness = DesiredBrightness;
PointLight1->bVisible = true;
RootComponent = PointLight1;
Components.Add(PointLight1);
Sphere1 = PCIP.CreateDefaultSubobject<USphereComponent>(this, TEXT("Sphere1"));
Sphere1->InitSphereRadius(250.0f);
Sphere1->OnComponentBeginOverlap.AddDynamic(this, &ALightSwitchBoth::OnOverlap); // set up a notification for when this component overlaps something
Sphere1->OnComponentEndOverlap.AddDynamic(this, &ALightSwitchBoth::OnOverlap); // set up a notification for when this component overlaps something
Sphere1->AttachParent = RootComponent;
Components.Add(Sphere1); }
- Components doesn’t exist. There’s an API AddComponent
AActor::AddComponent(FName TemplateName, bool bManualAttachment, const FTransform& RelativeTransform, const UObject* ComponentTemplateContext)
but I’m not clear that it does the same thing. - AddDynamic is marked __internal
Are there equivalent APIs or am I just reading something wrong?
Yes, I’m aware this is very simple in blueprint, but I’m trying to crack the c++ side as a learning exercise.