Why my C++ version pawn don't have Input components when I play game

Why my C++ version pawn don’t have Input components when I play game

All actors have input components. It’s just not visible in the editor.

 if GetOwner()->FindComponentByClass<UInputComponent>()==nullptr;
UE_LOG();

and The Condition is true when I play Game

Are you playing the game in the editor or simulating?

play

In new editor window

if GetOwner()->FindComponentByClass<UInputComponent>()==nullptr; You finished the sentence with “;” so UE_LOG(); is not a part of the if.

Nope this was not my actual code I was just mentioning code was something like this within the if block

Do you have another pawn in the level? Could you change your message to be

if (GetOwner()->FindComponentByClass<UInputComponent>())
{
    UE_LOG(LogTemp, Warning, TEXT("%s has an input compomnent"), *GetOwner()->GetName())
}
else
{
    UE_LOG(LogTemp, Error, TEXT("%s does NOT have an input compomnent"), *GetOwner()->GetName())
}

I changed but else{} block is executing Until I make a Blueprint version of my C++ character Class

But what isn’t getting it? Only the player would have one.

yeah Now It’s Working!
I compiled 3 to 6 times May be it’s cause Unreal

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms