Hi
I’ve encountered a strange behavior in the unreal engine 5 and I have no idea how to fix it.
When I create a blueprint from a C++ the mesh behaves strangely in a skeleton mesh, not what I expect. But only it’s from a C++ class. If I just create the same structure in blueprint it works fine. But see yourself, What happened to the hair?
the header file:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "Test_Pawn_Class.generated.h"
UCLASS()
class TESTPROJECT_API ATest_Pawn_Class : public APawn
{
GENERATED_BODY()
public:
// Sets default values for this pawn's properties
ATest_Pawn_Class();
// Called every frame
virtual void Tick(float DeltaTime) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
private:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
class UCapsuleComponent* CapsuleComp;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
class USkeletalMeshComponent* Mesh;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
class USkeletalMeshComponent* Hair;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
class USkeletalMeshComponent* Cloth;
};
the cpp file
// Fill out your copyright notice in the Description page of Project Settings.
#include "Test_Pawn_Class.h"
#include "Components/CapsuleComponent.h"
#include "Engine/SkeletalMesh.h"
// Sets default values
ATest_Pawn_Class::ATest_Pawn_Class()
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
CapsuleComp = CreateDefaultSubobject<UCapsuleComponent>(TEXT("Capsule Collider"));
RootComponent = CapsuleComp;
Mesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Body"));
Mesh->SetupAttachment(RootComponent);
Hair = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Hair"));
Hair->AttachToComponent(Mesh,FAttachmentTransformRules(EAttachmentRule::SnapToTarget, true),TEXT("Hair"));
//Hair->SetupAttachment(Mesh);
Hair->SetMasterPoseComponent(Mesh);
Cloth = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Cloth"));
Cloth->AttachToComponent(Mesh,FAttachmentTransformRules(EAttachmentRule::SnapToTarget, true),TEXT("Cloth"));
//Hair->SetupAttachment(Mesh);
Cloth->SetMasterPoseComponent(Mesh);
}
// Called when the game starts or when spawned
void ATest_Pawn_Class::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ATest_Pawn_Class::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void ATest_Pawn_Class::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}
what it looks:
same structur only blueprint:
Any idea what happend and how i can solve this?