I have a base c++ class for our game characters called Being, and I have a custom actor component that I want to have in it as a DefaultComponent… Everything was fine until I moved from 4.15 to 4.17
Now when I play the game with a character Blueprint-Inherited from this class, I always get a None value… Am I doing something wrong? I followed the creation code of UCharacterMovementComponent in Character.h and Character.cpp to the last word.
Being.h
ABeing(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
//Name of the CounterHolder component
static FName CounterComponentName;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "General|Being|Public", meta = (AllowPrivateAccess = "true"))
class UCounterHolder *CounterHolder;
Being.cpp
FName ABeing::CounterComponentName(TEXT("CountHoldComp"));
ABeing::ABeing(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
PrimaryActorTick.bCanEverTick = true;
//Do not use ControllerYaw to rotate character's mesh, use velocity's direction to rotate the mesh instead
bUseControllerRotationYaw = false;
if (GetCharacterMovement()) {
GetCharacterMovement()->bOrientRotationToMovement = true;
}
//Create CounterHolder as default component to being, set it to replicate and activate on it's own
CounterHolder = CreateDefaultSubobject<UCounterHolder>(ABeing::CounterComponentName);
if (CounterHolder) {
CounterHolder->SetIsReplicated(true);
CounterHolder->bAutoActivate = true;
}
}
I didn’t mention it but, my actor component is not a charactermovement component, it inherits directly from UActorComponent. My charactermovement component instantiates just fine. My actor component was introduced on ABeing that inherits from ACharacter
Yep, all of this was right. The strangest part is that I spawn other Actors from this component, and they really are spawned, so something is wrong here, it exists, but it doesn’t? It show on the list of components in blueprintclass, but when selected never shows on detail panels
Ok… Discovered that the important part is that a went from 4.15 to 4.17.
Seems like a bug, but I deleted the blueprint class, and recreated it and it solved the problem… The downside is that I needed to re-do all the functionality on the new blueprint class…
I had a similar problem, and did in fact notice it worked if I created a new child blueprint class based on the C++ class. I managed to fix the problem by renaming the component variable.