Unreal 5.3.2
Hi,
We are trying to access individual elements in a geometry collection once the object has been fractured, we saw we could access them via the ChaosBreakEvent but actually its only the parent and we can’t apply things to a specific element except for the linear velocity that takes in an index
But for instance if we change the scale of the element, it changes the scale for the parent and every child.
We tried to put the elements in a array but its always the parent that gets into the array and not the children
If there another way to achieve that, even in C++ if that is needed ?
Thanks
What you could do is instead of trying to access them like this, make your own pre-fractured Meshes - that can be done in Blender, Houdini etc and then import them as separated meshes. That way you can control them via code easily
Here’s one way to access to particle in C++
void ACustomGCActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
const FGeometryCollectionPhysicsProxy* PhysicsProxy = GeometryCollectionComponent->GetPhysicsProxy();
// Skip particle 0 which is the root
for (int32 i = 1; i < GeometryCollectionComponent->GetDynamicCollection()->GetNumTransforms(); ++i)
{
if (Chaos::FPBDRigidClusteredParticleHandle* Particle = PhysicsProxy->GetParticle_Internal(i))
{
// This is the world location
Chaos::TVector<double, 3> Location = Particle->GetX();
}
}
}
There’s a deeper level to this which I’m still trying to figure out. Not all the particles move when the geometry collection moves, they only register a new location when they break all the way apart.
This code comment from GeometryCollectionEngine → GeometryCollectionComponent.cpp:2135 may shed some light on the problem:
We need to build a snapshot of the GC
We rely on the fact that clusters always fracture with one off pieces being removed.
This means we only need to record the one offs that broke and we get the connected components for free
The cluster properties are replicated with the first child of each connected component. These are always children that are known at author time and have a unique id per component
If the first child is disabled it means the properties apply to the parent (i.e. the cluster)
If the first child is enabled it means it’s a one off and the cluster IS the first child