[Chaos] Resetting chaos destruction

Hi, we’re using chaos cache manager to destroy objects in the game. We have a situation where when the player dies, we want to respawn them onto a checkpoint before the destruction. Hence, we need a way of resetting the destruction back to the initial state.

On the cache manager, we’re using the triggered play mode since when we set it to static pose mode, the geometry collection doesn’t seem to have any collisions. We’ve tried calling all the random function we could find that looked like could help including:

UGeometryCollectionComponent::EditRestCollection()
UGeometryCollectionComponent::RecreatePhysicsState()
UGeometryCollectionComponent::ResetDynamicCollection()
UGeometryCollectionComponent::RefreshEmbeddedGeometry()
AChaosCacheManager::BeginEvaluate()
AChaosCacheManager::EndEvaluate()

We’ve tried calling different combinations of these functions, with mixed results. Everything from resetting the visuals but not the collisions, to resetting the collisions and the visuals, but being unable to play the cache again.

What’s the proper way of resetting the geometry collection and replaying the cache?

Thank you for your help.

3 Likes

I faced the same issue with Chaos Cache Player(Chaos Cache Collection). I have Enemies in my game and when the enemy is destroyed at runtime, same instance of CCC has to play straight away. I’d like to avoid spawning new CCPlayer every time next enemy is destroyed. I need to playback same Chaos Cache Collection in sequence player.

The problem was that the AChaosCacheManager::TriggerAll() function will work only once for one instance of CCPlayer.
Actually, I didn’t find a way without prorgamming how to re-play same CCC at runtime.

This approach is working good for me on UE5.3. I’m running these functions before every next Trigger of Chaos Cache Player.

It will emulate re-intialize of CCC without extra cost of spawning. I hope it helps someone.

void UMyGameGameInstanceSubsystem::BeginRePlayCCC(AChaosCachePlayer* ChaosCachePlayer)
{
ChaosCachePlayer->RouteEndPlay(EEndPlayReason::Type::LevelTransition);
ChaosCachePlayer->DispatchBeginPlay(false);
}