Need help trying to get owner and character in playerstate

I am trying to get the player character in blueprint in my playerstate. I can get it in c++ with out problems but the cast in blueprint always fails.

Here’s the c++ thing I am trying to accomplish in blueprint in my playerstate class


AController* OwnerController = Cast<AController>(GetOwner());
if(OwnerController != NULL)
{
    AFirstPersonCharacter* OwnerCharacter = Cast<AFirstPersonCharacter>(OwnerController->GetCharacter());
    if (OwnerCharacter != NULL)
    {
        OwnerCharacter->testfunction();
    }
}

Here’s the Blueprint function

I am fairly sure I am looking at this wrong but I’ve been at this for many hours over quite a few days and could just have tunnel vision.

thanks MK

Looks to me like you’re trying to cast the owner to a character. Don’t you mean to use Get Player Character instead of Get Owner in that context? If you aren’t calling that from within the player’s controller, then you would also need to call a Get Player Controller before Get Player Character.

Hope this helps! :slight_smile: