将Actor附加到可变换组件的挂载点
2023年6月21日 2023年11月17日
说明
通过AActor::AttachToComponent将Actor附加到可变换组件的挂载点上, 要求已在组件上添加挂载点, 并提供以下信息
- |
---|
Actor |
可变换组件 |
挂载规则 |
挂载点名称 |
挂载函数 AActor::AttachToComponent
可变换组件: USceneComponent及其派生类
基类 | |
---|---|
UPrimitiveComponent | USceneComponent |
UMeshComponent | UPrimitiveComponent |
USkeletalMeshComponent | UMeshComponent |
UStaticMeshComponent | UMeshComponent |
挂载规则: FAttachmentTransformRules对象
FAttachmentTransformRules
说明
UE_5.1/Engine/Source/Runtime/Engine/Classes/Engine/EngineTypes.h
如何计算附加Actor的变换属性
数据成员
-
LocationRule, RotationRule和ScaleRule
- 对应变换属性的三个分量
- 使用EAttachmentRule进行设置
- 对应变换属性的三个分量
-
bInWeldSimulatedBodies
Whether to weld simulated bodies together when attaching
不知道效果, 设为false
构造函数
- 对变换属性的分量应用相同规则
1FAttachmentTransformRules(EAttachmentRule InRule, bool bInWeldSimulatedBodies) 2 : LocationRule(InRule) 3 , RotationRule(InRule) 4 , ScaleRule(InRule) 5 , bWeldSimulatedBodies(bInWeldSimulatedBodies) 6{}
- 为变换属性定制规则
1FAttachmentTransformRules(EAttachmentRule InLocationRule, EAttachmentRule InRotationRule, EAttachmentRule InScaleRule, bool bInWeldSimulatedBodies) 2 : LocationRule(InLocationRule) 3 , RotationRule(InRotationRule) 4 , ScaleRule(InScaleRule) 5 , bWeldSimulatedBodies(bInWeldSimulatedBodies) 6{}
EAttachmentRule
说明
UE_5.1/Engine/Source/Runtime/Engine/Classes/Engine/EngineTypes.h
如何计算附件Actor的最终变换矩阵
API
枚举成员
- | |
---|---|
SnapToTarget | Snaps transform to the attach point |
KeepWorld | Automatically calculates the relative transform such that the attached component maintains the same world transform |
KeepRelative | Keeps current relative transform as the relative transform to the new parent |
不知道区别, 使用SnapToTarget; 使用KeepRelative可以达到一样的效果