Hi my friends, i keep working on UE4.
I have created 2 C++ base classes:
Ark4GameMode
AJugador: public APawn
Then i derived both using BPs: ArkGameMode & APlayer_BP.
I have configured default game mode, and inside it, the APlayer_Bp as defaultPawnClass.
Here the Code:
UCLASS()
class ARK4_API AArk4GameMode : public AGameMode
{
GENERATED_BODY()
private:
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Clase AJugador", meta = (AllowPrivateAccess = "true"))
TSubclassOf<class AJugador> jugador;
TSubclassOf<class AJugador> claseBaseAJugador;
UPROPERTY()
class ACameraActor *camera;
UFUNCTION()
void setLevel();
public:
AArk4GameMode(const FObjectInitializer& ObjectInitializer);
UFUNCTION()
virtual void BeginPlay () override;
};
AArk4GameMode::AArk4GameMode(const class FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer){
AutoReceiveInput = EAutoReceiveInput::Player0;
//this->DefaultPawnClass = AJugador::StaticClass();
DefaultPawnClass = claseBaseAJugador;
}
UCLASS(Blueprintable)
class ARK4_API AJugador : public APawn
{
GENERATED_BODY()
private:
UPROPERTY()
class USceneComponent *sceneComponent;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="UStaticMesh de Jugador", meta=(AllowPrivateAccess="true"))
class UStaticMeshComponent* meshDeJugador;
[...] }
AJugador::AJugador(const class FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
PrimaryActorTick.bCanEverTick = true;
//AutoPossessPlayer = EAutoReceiveInput::Player0;
AutoReceiveInput = EAutoReceiveInput::Player0;
sceneComponent = CreateDefaultSubobject <USceneComponent>(TEXT("Scene Component _mine"));
RootComponent = sceneComponent;
meshDeJugador = ObjectInitializer.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("Mesh _mine"));
meshDeJugador->AttachTo(RootComponent);
}
void AJugador::BeginPlay()
{
Super::BeginPlay();
GEngine->AddOnScreenDebugMessage(-1, 10, FColor::Red, TEXT(" Pawn Created! "));
}
Well, as you can see, the code is not that complex, but the problem is that the APlayer_Bp is never beeing spawned
at all, in BeginPlay the “Pawn Created” message is never being called and the object never appear in object outliner.
if i change defaultPawnClass to : DefaultPawnClass= AJugador::StatiClass(); it works PARTIALLY, the object appears in the outliner but the mesh in never rendered.
if i drop the APlayer_Bp directly to the editor, the mesh of the pawn, appears without problem.
i Would really apreciate some help guys, i am really trying but nothing seems to work, please ask me questions or help me how should i do it many many thanks!
The idea is to do it completly in C++, without using BP scripting, i am allergic to it. the BPs i am using are just
Data BP to hold the meshes of my Pawn, Enemies etc…
i dont like Hard Coding the route of my asset in C++ neither i am allergit to that too.