Modular Pawn - Epic Wiki
# Modular Pawn
From Epic Wiki
Jump to: navigation, search
# Contents
# Overview
Contains code to create a basic modular pawn/character with separate head, body & legs.
NOTE: Created with & tested on UE4 beta. May be slight difference between it and public build.
# MyCharacter.h
GENERATED_UCLASS_BODY()
/**
* The skeletal mesh used for the body.
* Mesh (inherited from ACharacter) will act as characters head.
*/
UPROPERTY(Category=Character, VisibleAnywhere, BlueprintReadOnly)
TSubobjectPtr
/** * Name of the BodyComponentName. * Use this name if you want to prevent creation of the component (with PCIP.DoNotCreateDefaultSubobject). */ static FName BodyComponentName;
/**
* The skeletal mesh used for the legs.
* Mesh (inherited from ACharacter) will act as characters head.
*/
UPROPERTY(Category=Character, VisibleAnywhere, BlueprintReadOnly)
TSubobjectPtr
/** * Name of the BodyComponentName. * Use this name if you want to prevent creation of the component (with PCIP.DoNotCreateDefaultSubobject). */ static FName LegsComponentName;
}
# MyCharacter.cpp
AMyCharacter::AMyCharacter(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
static FName CollisionProfileName(TEXT("IgnoreOnlyPawn"));
Body = PCIP.CreateOptionalDefaultSubobject
// Mesh acts as the head, as well as the parent for both animation and attachment.
Body->AttachParent = Mesh;
Body->SetMasterPoseComponent(Mesh);
Components.Add(Body);
}
Legs = PCIP.CreateOptionalDefaultSubobject
// Mesh acts as the head, as well as the parent for both animation and attachment.
Legs->AttachParent = Mesh;
Legs->SetMasterPoseComponent(Mesh);
Components.Add(Legs);
}
}
# Usage
- Create a blueprint based on this character.
- Under the components tab, find the body & legs components
- Set the skeletal meshes the body & legs should use.
Retrieved from "https://wiki.unrealengine.com/index.php?title=Modular_Pawn&oldid=797"