Greetings, I’m currently using the Chaos destruction system with the field system component in order to activate the destruction.
It is all working correctly, however, when activating a field system the cape in my character (which is made with Chaos Cloth) gets bugged and becomes frozen.
The working field system is currently using the following code:
void AExplosionFieldSystemActor::Explode()
{
UFieldSystemComponent* FSystemComponent = GetFieldSystemComponent();
if (FieldSystemComponent)
{
float SphereRadius = ExplosionArea->GetScaledSphereRadius();
FVector CenterPosition = ExplosionArea->GetComponentLocation();
// Strain Field
FieldSystemComponent->ApplyStrainField(true, CenterPosition, SphereRadius, StrainMagnitude, 1);
// Linear Velocity Field
FieldSystemComponent->ApplyUniformVectorFalloffForce(true, CenterPosition, GetActorForwardVector(), SphereRadius, VelocityMagnitude);
// Delete after explosion to avoid physics inconsistencies
Destroy();
}
}
But this doesn’t allow to use the MetaData filter seen here: https://docs.unrealengine.com/5.0/en-US/API/Runtime/FieldSystemEngine/Field/UFieldSystemComponent/ in various functions.
With this, I tried to use the ApplyPhysicsField() function since it does allow to setup the filter.
However, using the field system this way doesn’t work, Chaos destruction isn’t activated. The implementation looks like this:
AExplosionFieldSystemActor::AExplosionFieldSystemActor()
{
// ............. Other vars being set in constructor
MetaData = CreateDefaultSubobject<UFieldSystemMetaDataFilter>(TEXT("MetaData"));
MetaData->SetMetaDataFilterType(EFieldFilterType::Field_Filter_All, EFieldObjectType::Field_Object_Cloth, EFieldPositionType::Field_Position_CenterOfMass);
RadialFalloff = CreateDefaultSubobject<URadialFalloff>(TEXT("RadialFalloff"));
UniformVector = CreateDefaultSubobject<UUniformVector>(TEXT("UniformVector"));
}
void AExplosionFieldSystemActor::Explode()
{
UFieldSystemComponent* FSystemComponent = GetFieldSystemComponent();
if (FieldSystemComponent)
{
// Strain Field
DetermineRadialFalloff();
FieldSystemComponent->ApplyPhysicsField(true, EFieldPhysicsType::Field_ExternalClusterStrain, MetaData, RadialFalloff);
// Linear Velocity Field
DetermineUniformVector();
FieldSystemComponent->ApplyPhysicsField(true, EFieldPhysicsType::Field_LinearVelocity, MetaData, UniformVector);
// Delete after explosion to avoid physics inconsistencies
Destroy();
}
}
void AExplosionFieldSystemActor::DetermineRadialFalloff()
{
float SphereRadius = ExplosionArea->GetScaledSphereRadius();
FVector CenterPosition = ExplosionArea->GetComponentLocation();
RadialFalloff->SetRadialFalloff(StrainMagnitude, 0.0f, 1.0f, 0.0f, SphereRadius, CenterPosition, EFieldFalloffType::Field_FallOff_None);
}
void AExplosionFieldSystemActor::DetermineUniformVector()
{
UniformVector->SetUniformVector(VelocityMagnitude, GetActorForwardVector());
}
Any ideas on how to make this work? Everything is set according to the documentation, but it simply doesn’t work, not even setting the filter to affect all makes it work.
Thanks for any tips.