void ADA2UE4Creature::InitSkeletalMeshComponent(TWeakObjectPtr<class USkeletalMeshComponent> SMeshPointer, bool AttachToParent) { SMeshPointer->AlwaysLoadOnClient = true; SMeshPointer->AlwaysLoadOnServer = true; SMeshPointer->bOwnerNoSee = false; SMeshPointer->MeshComponentUpdateFlag = EMeshComponentUpdateFlag::AlwaysTickPose; SMeshPointer->bCastDynamicShadow = true; SMeshPointer->bAffectDynamicIndirectLighting = true; SMeshPointer->PrimaryComponentTick.TickGroup = TG_PrePhysics; // force tick after movement component updates if (GetCharacterMovement()) { SMeshPointer->PrimaryComponentTick.AddPrerequisite(this, GetCharacterMovement()->PrimaryComponentTick); } //SMeshPointer->AttachParent = GetCapsuleComponent(); SMeshPointer->SetupAttachment(GetCapsuleComponent()); static FName CollisionProfileName(TEXT("CharacterMesh")); SMeshPointer->SetCollisionObjectType(ECC_Pawn); SMeshPointer->SetCollisionProfileName(CollisionProfileName); SMeshPointer->bGenerateOverlapEvents = false; // Mesh acts as the head, as well as the parent for both animation and attachment. if (AttachToParent) { //SMeshPointer->AttachParent = MeshHEDComponent; SMeshPointer->SetupAttachment(MeshHEDComponent); SMeshPointer->SetMasterPoseComponent(MeshHEDComponent); SMeshPointer->bUseBoundsFromMasterPoseComponent = true; } }