2024-05-16 17:18:33 +08:00
|
|
|
|
# 前言
|
2024-05-24 17:55:01 +08:00
|
|
|
|
继承关系:BP_XXX_Base -> BP_Idol_Base -> TsIdolActor -> AVCharacter -> ACharacter 。
|
2024-05-16 17:18:33 +08:00
|
|
|
|
主要逻辑位于TsIdolActor中,文件路径为`Script/LiveDirector/Character/TsIdolActor.ts`
|
|
|
|
|
|
2024-06-11 16:29:30 +08:00
|
|
|
|
# 添加新衣服流程
|
|
|
|
|
1. 在Content/Character/XXX中创建继承自BP_XXX_Base的蓝图。
|
2024-06-26 16:37:01 +08:00
|
|
|
|
2. 设置SkeletalMesh。并且确保勾选了**Dynamic InsetShadow**。
|
|
|
|
|
3. 添加PhysicalAsset,并且保证胶囊体大致包裹模型,否则阴影会出现被裁剪的问题。
|
|
|
|
|
4. 添加对应的OutlineMaterial。
|
2024-06-11 16:29:30 +08:00
|
|
|
|
5. 在DressName中输入新衣服的显示名称。
|
|
|
|
|
6. 添加Prop标签。
|
|
|
|
|
1. Idol.XXX
|
|
|
|
|
2. Prop.Dress(第一件衣服需要设置成Prop.Dress.Default)
|
|
|
|
|
3. Prop.MountPoint.Body
|
|
|
|
|
7. ***脚本扫描***:点击编辑器的嘉然头像->角色道具配置全量生成 or 角色道具配置增量生成。会往IdolPropAssetConfig.json添加对应衣服或者道具配置数据。
|
2024-06-06 11:05:04 +08:00
|
|
|
|
# 添加新角色流程笔记
|
|
|
|
|
1. 添加一个Idol.xxx标签。
|
2024-06-11 11:50:34 +08:00
|
|
|
|
2. 修改下面相关文件[[#含有角色标签的文件]]。
|
|
|
|
|
3. 添加对应的蓝图与文件结构。
|
|
|
|
|
1. Content/Character
|
2024-06-11 16:29:30 +08:00
|
|
|
|
1. 在Idol_Base中添加[[#BP_XXX_Base]]。
|
2024-06-26 16:37:01 +08:00
|
|
|
|
2. 设置衣服、头发的SkeletalMesh。并且确保勾选了**Dynamic InsetShadow**。
|
|
|
|
|
3. 添加角色、衣服、头发的PhysicalAsset,并且保证胶囊体大致包裹模型,否则阴影会出现被裁剪的问题。
|
2024-06-11 11:50:34 +08:00
|
|
|
|
2. Content/ResArt/CharacterArt:放置角色与服装,按照
|
2024-06-18 10:40:05 +08:00
|
|
|
|
1. 动画蓝图中的***FullBody节点需要设置角色标签***。
|
|
|
|
|
1. 指定用于修型的PostProcess动画蓝图。
|
|
|
|
|
2. 添加Prop标签。
|
2024-06-11 16:29:30 +08:00
|
|
|
|
1. Idol.XXX
|
|
|
|
|
2. Prop.Dress
|
|
|
|
|
3. Prop.MountPoint.Body
|
2024-06-18 10:40:05 +08:00
|
|
|
|
3. ***脚本扫描***:点击编辑器的嘉然头像->角色道具配置全量生成 or 角色道具配置增量生成。会往IdolPropAssetConfig.json添加对应衣服或者道具配置数据。
|
2024-06-26 14:58:59 +08:00
|
|
|
|
4. 设置道具挂载信息数据表:ResArt/MountPointConfig/DT_MountPointConfig:用于设置道具挂载时的相对偏移。
|
|
|
|
|
5. ***材质相关操作***:
|
2024-06-25 18:41:14 +08:00
|
|
|
|
1. 在ResArt/CommonMaterial/Functions/CameraLightCollection中添加对应角色的属性。
|
|
|
|
|
2. 在ResArt/CommonMaterial/Functions/MF_CharacterMainLightIntensity中添加对应RoleID。
|
2024-06-27 18:21:54 +08:00
|
|
|
|
3. 在ResArt/CommonMaterial/Functions/MF_CharacterRimLightIntensity中添加对应RoleID。
|
|
|
|
|
4. 在对应角色的基础材质中设置RoleID数值。
|
|
|
|
|
5. 调用Python脚本制作Dissolve材质。LiveDirector/Editor/MaterialMigration/MakeDissolveMaterials.py
|
2024-06-25 18:41:14 +08:00
|
|
|
|
|
2024-06-11 11:50:34 +08:00
|
|
|
|
## 含有角色标签的文件
|
2024-06-18 11:12:04 +08:00
|
|
|
|
1. [x] TsCharacterItem.ts `Script/LiveDirector/Character/View/TsCharacterItem.ts`
|
2024-06-07 14:16:13 +08:00
|
|
|
|
1. 3级角色控制界面相关的UI操作。
|
|
|
|
|
2. [x] TsCharacterMocapViewTmp.ts :这个是MotionProcess的UI,继承控件`/Content/UIAssets/Character/Mocap/WBP_CharacterMocapViewTmp`
|
|
|
|
|
1. 在MotionProcess专用地图中创建对应的Idol。
|
|
|
|
|
3. [x] TsPropMocapItemTmp.ts
|
|
|
|
|
1. 在MotionProcess专用地图中控制道具Attach到对应Idol(UI逻辑)
|
|
|
|
|
4. [x] TsDirectorConsoleCommandHandler.ts
|
|
|
|
|
1. 快捷命令 Motion同步相关 GetMotionOffset
|
|
|
|
|
2. 快捷命令 快速创建4个角色 IdolCostume
|
|
|
|
|
5. [x] TsSpawnPointSettingItem.ts
|
|
|
|
|
1. IdolItemUI,继承控件`/Content/UIAssets/Character/WBP_SpawnPointSettingItem`
|
2024-06-11 11:50:34 +08:00
|
|
|
|
6. [x] TsIdolPropManagerComponent.ts
|
2024-06-07 14:16:13 +08:00
|
|
|
|
1. 没有思诺与心怡
|
|
|
|
|
2. 需要搞清楚。
|
|
|
|
|
7. [x] ~~TsSimpleLevelManager.ts~~
|
|
|
|
|
1. SwitchLiveArea()中调用,只调用了Idol.BeiLa,属于容错语句。
|
|
|
|
|
8. ~~CameraDebug.cpp ~~(这个不需求)
|
2024-06-11 16:29:30 +08:00
|
|
|
|
|
|
|
|
|
## BP_XXX_Base
|
|
|
|
|
1. 指定动画蓝图。
|
|
|
|
|
2. 指定LiveLinkName。
|
|
|
|
|
3. 指定OutlineMaterial。
|
|
|
|
|
|
2024-05-24 18:21:55 +08:00
|
|
|
|
# AVCharacter
|
|
|
|
|
主要实现了`virtual void OnRep_AttachmentReplication() override;`,声明了若干BlueprintNativeEvent:
|
|
|
|
|
- bool CanSyncRelativeTransform();
|
|
|
|
|
- void BeforeAttachToNewParent();
|
|
|
|
|
- void AfterAttachToNewParent();
|
|
|
|
|
|
|
|
|
|
## OnRep_AttachmentReplication()
|
|
|
|
|
注释:
|
|
|
|
|
>// 动捕模式下,CanSync=false. 各端自行计算Actor Location, client无需使用Server计算结果
|
2024-05-27 12:39:37 +08:00
|
|
|
|
// 自由行走模式下, CanSync=true,client需要同步server的transform信息。
|
2024-05-16 17:18:33 +08:00
|
|
|
|
|
2024-05-28 10:21:57 +08:00
|
|
|
|
同步Attachment行为。在AActor::OnRep_AttachmentReplication()的基础上添加:
|
2024-05-28 11:17:28 +08:00
|
|
|
|
- 判断CanSync标记,以此来决定是否同步Transform
|
|
|
|
|
- 未Attach组件=>Attch组件前后添加BeforeAttachToNewParent()、AfterAttachToNewParent()
|
2024-05-27 12:39:37 +08:00
|
|
|
|
```c++
|
2024-05-28 11:17:28 +08:00
|
|
|
|
auto CanSync = CanSyncRelativeTransform(); //获取Sync标记,具体的逻辑位于TsIdolActor.ts中
|
|
|
|
|
if (attachmentReplication.AttachParent)
|
|
|
|
|
{
|
|
|
|
|
if (RootComponent)
|
2024-05-27 12:39:37 +08:00
|
|
|
|
{
|
2024-05-28 11:17:28 +08:00
|
|
|
|
USceneComponent* AttachParentComponent = (attachmentReplication.AttachComponent ? attachmentReplication.AttachComponent : attachmentReplication.AttachParent->GetRootComponent());
|
|
|
|
|
if (AttachParentComponent)
|
2024-05-27 12:39:37 +08:00
|
|
|
|
{
|
2024-05-28 11:17:28 +08:00
|
|
|
|
if(CanSync)//增加判断Sync判断,只有在自由行走模式下才会同步Transform。
|
2024-05-27 12:39:37 +08:00
|
|
|
|
{
|
2024-05-28 11:17:28 +08:00
|
|
|
|
RootComponent->SetRelativeLocation_Direct(attachmentReplication.LocationOffset);
|
|
|
|
|
RootComponent->SetRelativeRotation_Direct(attachmentReplication.RotationOffset);
|
|
|
|
|
RootComponent->SetRelativeScale3D_Direct(attachmentReplication.RelativeScale3D);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If we're already attached to the correct Parent and Socket, then the update must be position only.
|
|
|
|
|
// AttachToComponent would early out in this case.
|
|
|
|
|
// Note, we ignore the special case for simulated bodies in AttachToComponent as AttachmentReplication shouldn't get updated
|
|
|
|
|
// if the body is simulated (see AActor::GatherMovement).
|
|
|
|
|
const bool bAlreadyAttached = (AttachParentComponent == RootComponent->GetAttachParent() && attachmentReplication.AttachSocket == RootComponent->GetAttachSocketName() && AttachParentComponent->GetAttachChildren().Contains(RootComponent));
|
|
|
|
|
if (bAlreadyAttached)
|
|
|
|
|
{
|
|
|
|
|
// Note, this doesn't match AttachToComponent, but we're assuming it's safe to skip physics (see comment above).
|
|
|
|
|
if(CanSync)
|
2024-05-27 12:39:37 +08:00
|
|
|
|
{
|
2024-05-28 11:17:28 +08:00
|
|
|
|
RootComponent->UpdateComponentToWorld(EUpdateTransformFlags::SkipPhysicsUpdate, ETeleportType::None);
|
2024-05-27 12:39:37 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-28 11:17:28 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
BeforeAttachToNewParent();//增加BlueprintNativeEvent
|
|
|
|
|
RootComponent->AttachToComponent(AttachParentComponent, FAttachmentTransformRules::KeepRelativeTransform, attachmentReplication.AttachSocket);
|
|
|
|
|
AfterAttachToNewParent();//增加BlueprintNativeEvent
|
|
|
|
|
}
|
2024-05-27 12:39:37 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-28 11:17:28 +08:00
|
|
|
|
}
|
2024-05-27 12:39:37 +08:00
|
|
|
|
```
|
2024-05-27 12:00:54 +08:00
|
|
|
|
|
2024-05-24 18:21:55 +08:00
|
|
|
|
# TsIdolActor.ts
|
|
|
|
|
## VirtualOverrider
|
2024-05-28 11:17:28 +08:00
|
|
|
|
CanSyncRelativeTransform()
|
|
|
|
|
- 不需要同步Transform的情况
|
|
|
|
|
- AI控制的ACao角色不需要同步。
|
|
|
|
|
- 使用TsIdolMovementComponent并且勾选了ManulMovement的情况不需要同步。
|
|
|
|
|
- 动画蓝图中使用了**AnimGraphNode_Fullbody**节点,并且bGetMotionData为true的情况不需要同步。
|
2024-05-24 18:21:55 +08:00
|
|
|
|
|
2024-05-28 11:17:28 +08:00
|
|
|
|
具体代码如下:
|
2024-05-24 18:21:55 +08:00
|
|
|
|
```typescript
|
|
|
|
|
CanSyncRelativeTransform(): boolean {
|
|
|
|
|
if (Utils.HasTag(this.PropTags, new UE.GameplayTag("Idol.AIACao"))) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if(this.MovementComp && this.MovementComp.ManulMovement){
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
var animInstance = this.Mesh.GetAnimInstance() as UE.IdolAnimInstance
|
|
|
|
|
let fullbodyNode = Reflect.get(animInstance, 'AnimGraphNode_Fullbody') as UE.AnimNode_FullBody
|
|
|
|
|
return !(fullbodyNode && fullbodyNode.bGetMotionData)
|
|
|
|
|
}
|
2024-06-11 17:00:36 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# Prop.Dress.Default
|
2024-06-11 17:24:23 +08:00
|
|
|
|
1. TsIdolPropManagerComponent.ts ServerLoadProp()
|
|
|
|
|
2. DoLoadProp()
|
|
|
|
|
3. ServerDoLoadPropPreset()
|
|
|
|
|
4. GetPropPreset()
|
|
|
|
|
5. GetDefaultDress():取得DefaultDress标签字符串。
|
|
|
|
|
6. GetPropAssetConfigsByTags(tags):根据标签取得对应的资产配置(UPropAssetConfig)
|
|
|
|
|
|
|
|
|
|
扫描所有资产:TsPropAssetManager.ts CollectAllAssets()
|