跳转到内容
CRUSHFORMV1.1.0
在 Fab 上获取

参考组件

UCFVehicleAdapterComponent

模块CrushformVehicle头文件CFVehicleAdapterComponent.h父类UActorComponent

蓝图:Crushform Vehicle Adapter

无需代码即可为车辆添加 Crushform。添加到任何 Actor 上后,它会创建凹陷与污垢、玻璃、轮胎、滚动声音与 FX、发动机声音、道具破坏以及撞击反馈,并回答这些功能关于车辆的问题:由哪一端模拟它、车轮在何处接触地面、哪些网格体是车轮、其发动机如何运转(即下述发动机事件,可由子类或蓝图覆盖)。每一端都以相同名称创建相同的组件,因此被复制的组件彼此对应。此通用适配器会追踪 Wheels 中选定的车轮;车辆系统的适配器(UCFChaosVehicleAdapterComponent)则改为读取该系统自身的车轮。压上障碍物的轮胎会通过适配器把其车轮从障碍物上推开,适配器会把这份推挤保持在车轮网格体上,直到轮胎再次请求;覆盖了 SetCrushformTireWheelOffsets 的蓝图会自行摆放车轮,并关闭这种推挤。父级相对于车身转动的车轮,例如转向节,在转动期间会得到错误的推挤。

函数

AUTHORITY · 服务器,每个端LOCAL · 本机PURE · 只读
ECFEngineRunState GetEngineRunState() const
PURE

发动机是否处于关闭、启动或运行状态。本适配器:始终为关闭;由车辆系统适配器或蓝图子类给出实际值。

分类
Crushform|Engine
float GetEngineRPM() const
PURE

发动机转速,单位 rpm。本适配器:0。

分类
Crushform|Engine
float GetEngineIdleRPM() const
PURE

怠速转速,单位 rpm:运行中的发动机的声音永远不会低于此值。本适配器:0。

分类
Crushform|Engine
float GetEngineMaxRPM() const
PURE

最高发动机转速,单位 rpm;0 表示无限制。本适配器:0。

分类
Crushform|Engine
float GetEngineLoad() const
PURE

油门,范围 0..1。本适配器:0。

分类
Crushform|Engine
void BuildWheelContacts(TArray<FCFWheelContact>& OutContacts)

该帧的车轮,每帧在 tick 中调用一次。本适配器追踪其车轮列表;车辆系统的适配器可以在 C++ 或蓝图子类中覆盖它,下面三个函数同样如此。

分类
Crushform|Vehicle
void CollectWheelMeshes(TArray<UMeshComponent*>& OutMeshes) const
PURE

车轮的网格:轮胎、车轮污垢,以及车身不会形变的网格。本适配器:其车轮列表中的网格。

分类
Crushform|Vehicle
void BuildTireWheels(TArray<FCFTireWheelDesc>& OutWheels) const
PURE

车轮的轮胎,各自包含其网格、物理半径、HostIndex、当前偏移量以及 bAcceptsPush。本适配器:其车轮列表;除非 Blueprint 子类通过脚本实现 SetCrushformTireWheelOffsets(AcceptsTirePush),否则它会接受推挤。

分类
Crushform|Vehicle
void BuildLoadRatios(TArray<float>& OutRatios) const
PURE

按 HostIndex 划分的接触力与标称载荷之比;本适配器没有力模型,因此不提供任何值。

分类
Crushform|Vehicle
void SetWheels(const TArray<FCFAdapterWheelState>& InWheels)

替换 Wheels 中选定的车轮,用于运行时创建的车轮。可在 BeginPlay 之前调用。

分类
Crushform
void SetBraking(float Amount)

车辆的制动强度,范围 0..1,作用于每个车轮:制动时滚动 FX 会喷溅得更多。

分类
Crushform
void SetCabinMuffled(bool bMuffled)

当听者位于该车辆车厢内时,使滚动声和发动机声变闷:若 bOverrideCabinMuffling 为 true,则使用适配器的车厢数值;否则车轮使用 Crushform Wheels 设置中的值,发动机使用 Crushform Engine 设置中的值。

分类
Crushform
UCFDeformComponent* GetDeform() const
PURE

使车身凹陷的形变组件;没有 Dirt And Dents 时为 null。

分类
Crushform
UCFGlassUnitsComponent* GetGlass() const
PURE

保存车辆玻璃面板的组件;只有 Glass 和 Dirt And Dents 都开启时才存在,否则为 null。

分类
Crushform
UCFTireComponent* GetTires() const
PURE

轮胎组件;没有 Tires 时为 null。

分类
Crushform
UCFPropContactComponent* GetPropContact() const
PURE

用于破坏车辆撞入的道具的组件;没有 Breaks Props 时为 null。

分类
Crushform
UCFNetImpactFeedbackComponent* GetImpactFeedback() const
PURE

车身的撞击反馈组件;没有 Impact Feedback 时为 null。

分类
Crushform
UCFPartImpactFeedbackComponent* GetPartImpactFeedback() const
PURE

铰接部件的撞击反馈组件;只有 Impact Feedback 和 Dirt And Dents 都开启时才存在,否则为 null。

分类
Crushform
UCFRollingAudioComponent* GetRollingAudio() const
PURE

滚动声组件;没有 Rolling Sound 时为 null。

分类
Crushform
UCFRollingFXComponent* GetRollingFX() const
PURE

滚动特效组件;没有 Rolling FX 时为 null。

分类
Crushform
UCFEngineAudioComponent* GetEngineAudio() const
PURE

发动机声组件;没有 Engine Sound 时为 null。

分类
Crushform
FCFDamageZones GetDamageZones() const
PURE

形变组件的 Get Damage Zones:车身每一侧的凹陷程度,以服务器确认的结果为准。没有 Dirt And Dents 时全部为零。

分类
Crushform|Damage
FCFDamageValues GetDamageInBox(const FBox& Box) const
PURE

形变组件的 Get Damage In Box:拥有者根空间中某个盒体内的损伤。没有 Dirt And Dents 时全部为零。

分类
Crushform|Damage
int32 GetWheelGatherCount() const
PUREC++ ONLY

本帧车轮被构建(BuildWheelContacts)的次数;测试会对其计数。

属性

ECFAuthorityModel Authority = ECFAuthorityModel::Server

决定由哪一端模拟车辆并判定其撞击。

默认值
ECFAuthorityModel::Server
分类
Crushform
TObjectPtr<UCFProfile> DeformProfile

车身的凹陷和污垢;为空时使用项目默认值(Project Settings -> Plugins -> Crushform)。

分类
Crushform
TObjectPtr<UCFTireProfile> TireProfile

轮胎;为空时使用项目默认值(Project Settings -> Plugins -> Crushform Tire)。

分类
Crushform
bool bDirtAndDents = true

车身会凹陷并变脏(UCFDeformComponent);玻璃面板和车轮污垢需要它。

默认值
true
分类
Crushform|Features
bool bGlass = true

车辆上的玻璃面板(UCFGlassComponent)会开裂和破碎;需要 Dirt And Dents,由它负责找到这些面板。

默认值
true
分类
Crushform|Features
bool bTires = true

轮胎在车轮网格上发生形变(UCFTireComponent)。

默认值
true
分类
Crushform|Features
bool bRollingSound = true

每个车轮播放其所在表面的滚动声(UCFRollingAudioComponent);仅为表现效果,专用服务器上静音。

默认值
true
分类
Crushform|Features
bool bRollingFX = true

每个车轮显示其所在表面的滚动特效(UCFRollingFXComponent);仅为表现效果,专用服务器上不显示。

默认值
true
分类
Crushform|Features
bool bEngineSound = true

发动机根据下方的发动机事件播放其声音(UCFEngineAudioComponent);仅为表现效果,专用服务器上静音。

默认值
true
分类
Crushform|Features
bool bImpactFeedback = true

撞击会在每一端上播放撞击声和特效(UCFNetImpactFeedbackComponent);开启 Dirt And Dents 后,铰接部件的撞击和碰撞也会播放,并且在每一端上基于其自身的物理模拟进行播放(UCFPartImpactFeedbackComponent)。

默认值
true
分类
Crushform|Features
bool bBreaksProps = true

车辆会打碎其撞上的可破坏道具(UCFPropContactComponent)。

默认值
true
分类
Crushform|Features
TArray<FCFAdapterWheel> Wheels

此通用适配器追踪的车轮;车辆系统的适配器则读取该系统的车轮,并忽略此项。

分类
Crushform|Wheels
TEnumAsByte<ECollisionChannel> GroundChannel = ECC_Visibility

车轮追踪地面所用的通道。

默认值
ECC_Visibility
分类
Crushform|Wheels
float GroundProbeMargin = 2.f

离地面这么近的轮胎仍视为接触地面,单位 cm:追踪从轮毂开始,而不是从胎面开始。

默认值
2.f
分类
Crushform|Wheels
FGameplayTag ImpactEventTag

撞击反馈在碰撞时播放的内容:默认为插件的 Crushform.Impact.Vehicle.Crash;为空则不播放撞击声。

分类
Crushform|Impact
float ImpactImpulsePerKgForFullIntensity = 600.f

以全强度播放的撞击的速度变化量,单位 cm/s;适配器生成撞击反馈时读取。与 UCFImpactFeedbackComponent 的默认值相同。

默认值
600.f
分类
Crushform|Impact
float ImpactMinImpulsePerKg = 50.f

速度变化量低于此值的撞击不播放任何声音,单位 cm/s;适配器生成撞击反馈时读取。与 UCFImpactFeedbackComponent 的默认值相同。

默认值
50.f
分类
Crushform|Impact
float PropContactMinSpeedCmS = 50.f

低于此速度时,车辆不会破坏任何道具,单位 cm/s;适配器生成道具接触时读取。与 UCFPropContactComponent 的默认值相同。

默认值
50.f
分类
Crushform|Props
bool bOverrideRollingSoundTuning = false

该车辆的滚动声使用 Rolling Sound Tuning,而非 Crushform Wheels 设置中的 Tuning;适配器生成滚动声时读取。

默认值
false
分类
Crushform|Rolling Sound
FCFRollingAudioTuning RollingSoundTuning
分类
Crushform|Rolling Sound
bool bOverrideCabinMuffling = false

Set Cabin Muffled 使用该车辆的 Cabin Volume Scale 和 Cabin Low Pass Frequency,而不是 Crushform Wheels 与 Crushform Engine 设置中的对应值。它同时使滚动声和发动机声变闷。

默认值
false
分类
Crushform|Cabin
float CabinVolumeScale = 0.8f
默认值
0.8f
分类
Crushform|Cabin
float CabinLowPassFrequency = 3000.f
默认值
3000.f
分类
Crushform|Cabin
bool bOverrideRollingFXTuning = false

该车辆的滚动特效使用 Rolling FX Tuning,而非 Crushform Wheels 设置中的 FX Tuning;适配器生成滚动特效时读取。

默认值
false
分类
Crushform|Rolling FX
FCFRollingFXTuning RollingFXTuning
分类
Crushform|Rolling FX
TObjectPtr<UCFEngineSoundProfile> EngineSoundProfile

发动机的声音;为空时使用项目默认值(Project Settings -> Plugins -> Crushform Engine)。适配器生成发动机声音时读取。

分类
Crushform|Engine Sound
FVector EngineSoundOffset = FVector::ZeroVector

发动机声音的播放位置,相对于拥有者的根组件;适配器生成发动机声音时读取。

默认值
FVector::ZeroVector
分类
Crushform|Engine Sound
float RamAllowanceMps = 15.f

在 Owning Client 权威模型下,客户端报告的撞击速度比车辆近期峰值速度快出多少(单位 m/s)时,服务器才会拒绝。

默认值
15.f
分类
Crushform

事件

FCFOnDamageChangedDynamicDelegate OnDamageChanged
(const FCFDamageZones& Zones)

形变组件的 On Damage Changed,原样转发:适配器在注册时自行创建该组件,因此蓝图可在此处绑定该事件。没有 Dirt And Dents 时,该事件永远不会触发。

分类
Crushform|Damage