Adding a capsule component makes my character have 0 health?

When I add

UPROPERTY(EditAnywhere)
class UCapsuleComponent* HeadCapsule;

to MainCharacter.h and

HeadCapsule = CreateDefaultSubobject<UCapsuleComponent>(TEXT("HeadCapsule"));
HeadCapsule->SetupAttachment(RootComponent);

to MainCharacter.cpp My main character no longer has any health and can not die (because DoDeadPeopleThings() is called in TakeDamage if bIsDead() is true, which also can only be called if we are trying to send damage to a character with greater than 0 health.

Without these 4 lines the game works properly, except headshots. Right now I’m calculating the height of the shot instead of what I hit. Is there something with setting a capsule to the root component that is messing things up? nothing makes sense.

I am trying to get my code on github but the publish is taking too long and I have to leave for work. If any more is needed I can share it in about 8.5 hours from the original post. Sorry for the delay and thank you in advanced if there’s any advice based on the given information!

Privacy & Terms