I have a single triangle Static mesh with a single sphere added to its collision. This is viewable in the Static mesh window when I toggle simple collision objects to view. I can also drag the static mesh into the viewport scene and itll spawn it and if I toggle ‘Collision’ in the viewport I can see the static mesh with its single triangle and the sphere collision object surrounding it.
Now - I have a Hierarchical instanced static mesh comp which I have set this Static mesh to for its instance spawning. I spawn one single instance at world center (0,0,0) for simplicity. I can see the spawned instance triangle - but not the collision sphere - even if I toggle collision in the viewport.
Things I’ve tried.
- Setting the HISM comp to
Collision_Comp = CreateDefaultSubobject<UII_InstSMComp>(TEXT(CAT_SM_COLL_SPHERE));
if (Collision_Comp)
{
Collision_Comp->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
Collision_Comp->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f));
Collision_Comp->SetGenerateOverlapEvents(true);
Collision_Comp->bDrawMeshCollisionIfSimple = true;
Collision_Comp->SetMobility(EComponentMobility::Movable);
Collision_Comp->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Block);
Collision_Comp->SetupAttachment(RootComponent);
Collision_Comp->SetEnableGravity(false);
}
I have also tried putting a sphere collision as the root and attaching the HISMC to it. In code where I spawn the instance I have looked to make sure everything is there with this
const int32 tmpCollIdx = tmpInstCollComp.AddInstance(FTransform::Identity, true);
TArray<FBodyInstance*> tmpBodies = Collision_Comp->InstanceBodies;
I can see in the tmpBodies container the physics body, and if I drill down into it I can see the actual SM and within it I can see in the AggGeom container the actual sphere and its paramters. I have other HISMCs that are visual only and container meshes that are for viewing but not interacting, and so I call “MarkRenderStateDirty();” when any updates occur on an instance and I can see them update, only the HISMC with the Sm that contains a single sphere collision Elem in the AggGeoms container does not show the sphere collision
I am aware of other methods like “GetInstancesOverlappingSphere()” and the box version - I have used them and that is fine for those types of selections but I’m wanting to solve this issue of the Sms collision geo not being propagated into the instance itself.
Thanks in advance - this one is really stopping me in my tracks.