// 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;
};
C++:
// 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->SetupAttachment(Mesh);
Hair->SetMasterPoseComponent(Mesh);
Cloth = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Cloth"));
Cloth->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);
}
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "TestCharacter.generated.h"
UCLASS()
class BALLROLL_API ATestCharacter : public APawn
{
GENERATED_BODY()
public:
// Sets default values for this pawn's properties
ATestCharacter();
// 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;
};
.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "TestCharacter.h"
#include "Components/CapsuleComponent.h"
#include "Components/SkeletalMeshComponent.h"
// Sets default values
ATestCharacter::ATestCharacter()
{
// 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"));
SetRootComponent(CapsuleComp);
Mesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Body"));
Mesh->SetupAttachment(RootComponent);
Hair = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Hair"));
Hair->SetupAttachment(Mesh);
Hair->SetMasterPoseComponent(Mesh, true);
Cloth = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Cloth"));
Cloth->SetupAttachment(Mesh);
Cloth->SetMasterPoseComponent(Mesh,true);
}
// Called when the game starts or when spawned
void ATestCharacter::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ATestCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void ATestCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}
root component with the method didn’t work either. There is no change to be seen.
In your example you only use have clothing meshes, that always worked for me too. You can see it in the dress.
For whatever reason, the hair mesh and the body mesh don’t work in other skeleton components except the skeleton mesh component “Body”. However, when I use other body meshes or hair meshes, the same thing always happens.
I imported the meshes again and also imported completely fresh ones, the behavior remains the same.
If I just build it as a blueprint and don’t use a C++ class, the meshes behave completely correctly.
What I noticed. The body and hair meshes behaves exactly opposite of the dresses. When I remove the body from the C++ blueprint, the dress lies strangely on the floor.
I also noticed that the dress is always based on the body mesh. It doesn’t matter whether I have the body in Mesh(body) or in Hair(hair). The behavior can be seen on my first screenshots.
The hair mesh always behaves strangely unless it is placed in the mesh(body). Hair(hair) or Dress(dress) makes no difference. The body behaves exactly the same way.
If I remove the body from the pure blueprint, then the clothes and hair remain normal.
For whatever reason, the Mesh(Body) Skeleton Mesh affects the other Skeleton Meches in the blueprint. It also makes no difference if I separate them from the mesh (body) in their herachie.
It definitely stems from Set Master Pose Component. If I set on begin play that the c++ hair gets disconnected by setting Set Master Pose Component to null it goes back to normal.
Looking at the skeletal structure between the hair and body you have messed up bone orientations:
pelvis x axis is pointing in different direction
head x axis is pointing in different direction
The body has x going to the side and y is down???
On the hair x is up axis and y is front for the joints that are in the body (spine,head, pelvis,neck).
This is why your hair is messing up.
Once you set master pose it will match the pelvis, head hence the rotations being misaligned.
You need to re-rig the hair having IDENTICAL oriented bones from the body (in terms the axis need to align)
Probably best to just clone the needed bones from the full rig to the hair and re-link the hair strand bones.