So, i’m trying using the node getClass in a playerController object, it returns “Blueprint”. Now, what i do need is a way to get “PlayerController”.
I know i can use a cast, but for what i’m actually doing, i need the true class, not the parent whatsoever class. Did anyone find a way to do that?
I’m using that structure in a Editor Utility Blueprint with a print right now. Any help will be appreciated
Found the answer, you cant in BP. But here is the C++ Solution
.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "MyBlueprintFunctionLibrary.generated.h"
/**
*
*/
UCLASS()
class DHERRAMIENTAS_API UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
UFUNCTION(BlueprintPure)
static UClass *GetObjectParentClass(UObject* item);
}
.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "MyBlueprintFunctionLibrary.h"
UClass *UMyBlueprintFunctionLibrary::GetObjectParentClass(UObject *Object)
{
//return Object->GetClass()->GetSuperClass();
auto* BP = Cast<UBlueprint>(Object);
UClass* ActualParent= nullptr;
if (BP->ParentClass)
ActualParent = BP->ParentClass;
return ActualParent;
}