How to change collision response on Chaos geometry collection

Hi,

Is it possible to change collision response on Chaos geometry collection after break event occurs?

What I want to achieve is, for example, to have a player collide with wall, but after that wall is broken into parts, I want the player to ignore any collision with spawned fractures.
Currently the only way the Collision Response is working is to set it in editor before play. However in play mode, changing collision response has no effect…

Here’s how I’m trying to change collision response after break event occurs:

4 Likes

I am having the same issue, anything I do to the collision after the game is playing has no effect on geometry collections after fracturing. I am desperate to find a solution and I’ll tell you if I find anything.

Also looking for a way to do this, haven’t had any luck myself.

I just tried this as well and couldn’t do it. It seems like it would need to be set on the EmbeddedGeometryComponents which are private.

But as a workaround I made a separate StaticMeshComponent with the undestroyed mesh and collision, while the GeometryCollectionComponent is invisible at the start and doesn’t have pawn collision. When I destroy the object I remove the StaticMeshComponent and make the GeometryCollectionComponent visible.

Facing same issue. The old destructible could do it fine. How is this considered production ready?

5 Likes

Geometry Collection components don’t have a Body Instance (at least, not in a traditional sense) so any function that relies on that will automatically fail. Instead, you can update the “Collision Group” of an individual particle in code, but this takes an int32, and I’m so far unsure what “group” each number maps to

1 Like

In a build of 5.1 this works for me.

Do you know when 5.1 will be released? Thx :smiley:

I have the same Issue , cant change the collision of the fractures pieces

It would be great to see the rest of the code, I tried this and didnt work for some reason

1 Like

This is not working for me in 5.1

2 Likes

Does Mouse maybe know how to fix it?

So basically, short of rewriting Chaos ourselves, there is no way to:

  • Prevent Begin Play from shattering a collection on the “load-in impulse” without delaying Simulate Physics or disabling Collision for the first few ticks (anchor field catches the collection as it starts to move but it doesn’t prevent the impulse).
  • Prevent objects of a collision type from damaging the collection prematurely (e.g. for cinematics), again without delaying Simulate Physics or disabling Collision until the desired time.
  • Record a cache of the fracture unless, on Begin Play, it is Simulating Physics, and is not Sleeping (“load-in impulse” wakes it from sleep anyway); and Collision is enabled for all ticks before the fracture. (Making collision responses the only not-working workaround I can see for timed/complex fractures in cinematics). IMHO, trigger-type caches should check this stuff on-trigger, not on-begin-play.
  • Chaos Solvers do not expose filters to blueprints, and since “Edit…” doesn’t work, there is no way to override filter functions with your own function (say, to prevent breaking before a certain time, or to decouple blocking and damage).

The workaround involving spawning blueprints of the collection does not allow you to cache the fracture result, because there is no Chaos Cache Component with adequately exposed variables and functions.

A potential workaround involving using a slightly scaled, hidden-in-game, duplicate of the collection to prevent early collisions on the visible collection seems unreliable since irregularly shaped collections do not completely line up and slight penetrations still break the visible collection early.

2 Likes

Chaos Solvers are the obvious solution (since theoretically you can prevent individual collisions, breaks, etc based on criteria), so you could write a C++ subclass to filter on anything you want and pick that as your solver. However, as noted in the engine source C++ comments for the solver logic, solvers are currently completely broken and do absolutely nothing (except make the geometry overlap everything no matter what settings are used). Even though some work on solver code was done for 5.2, I see no indication that the underlying issue was addressed, since the comments are still there.

I am currently trying to write a Blueprint Function Library to circumvent some of these limitations, but I have yet to find the code that prevents changes to collision settings or simulate state from propagating to the PhysicsProxy collection or the ChaosCacheManager’s Observed items. So far it just looks like changes should be taken into account and they simply aren’t. I considered that maybe the physics was operating completely on a copy, but I figure that would also mean that the on-screen version would never update either… Does anyone have any ideas, or can anyone with more familiarity with how the Engine implements this stuff point to where the code makes these distinctions?

EDIT: I’ve noticed that Destroy Actor and even Set Hidden In Game appear to have no effect if applied to a Geometry Collection Actor during gameplay, further leading me to believe that the collection we see on screen is a copy and not the same collection that appears in the outliner. Probably if we had a way to access whatever the real actor is, then some of these changes, such as collision changes, would finally work (but odd that Simulate Physics can be ticked live, although I think I’ve seen the code that handles that). Perhaps the easiest solution is to have a blueprint library expose that copy.

1 Like

I was struggling with the same issue. I am creating a destructible that would be kinematic and would be broken into pieces when hit with a sword, so chaos would be used only as an effect rather than gradually breaking the object into pieces.

To make that happen, I have the geometry collection collision profile set to Destructible which blocks my pawns, so I can’t walk through them and when I break it, I am disabling the collision against pawn channel, so the pieces would not affect the gameplay anymore.

It seems that Chaos uses FCollisionFilterData to filter collisions and there are properties called InitialSimFilter and InitialQueryFilter in GeometryCollectionComponent which are initialized based on collision profile set in the object when the component creates physics state.

Those are private properties but you can force update them by first setting collision profile or responses to channels and then call OnActorEnableCollisionChanged-function (only in C++) to update those Chaos collision filters.

For anybody else struggling with the same problem, here is the code I am using to toggle the kinematic geometry collection into dynamic and change it to ignore pawns:

void UFixedDestructibleComponent::ApplyDynamicFieldAndBreak()
{
	// Ignore pawns when broken
	SetCollisionResponseToChannel(ECC_Pawn, ECR_Ignore);

	// Refresh Chaos collision filter data
	OnActorEnableCollisionChanged();

	// Create field command to change kinematic state to dynamic state
	FFieldSystemCommand DynamicStateCommand = FFieldObjectCommands::CreateFieldCommand(EFieldPhysicsType::Field_DynamicState, new FUniformInteger((int32)Chaos::EObjectStateType::Dynamic));
	DynamicStateCommand.MetaData.Add(FFieldSystemMetaData::EMetaType::ECommandData_ProcessingResolution).Reset(new FFieldSystemMetaDataProcessingResolution(EFieldResolutionType::Field_Resolution_Maximum));
	DispatchFieldCommand(DynamicStateCommand);
}

I’ve derived a custom class from UGeometryCollectionComponent and added the function above into it. The field command there changes the whole geometry collection from kinematic to dynamic.

9 Likes

If youre trying to prevent the choas from starting when the game launches you might need to check your workflow. Currently im using a large stone mesh that when the player uses a pickaxe to gather stone is replaced with the geometry collection which when is replaced begins to fracture giving the result that looks like the player fractured the stone with the pickaxe. There are also other ways to achieve this depending on what your game is doing. It is possible to use field systems to cause the geometry collection sleep at the start of the game. There isnt much documentation on this but there are some video tutorials on youtube regarding the different field types used to affect the geometry collection.

Hi there ! Unreal 5.3 is out, still nothing about the possibility of changing the collision of debris?

2 Likes

I wish they would allow us to change the collision response of the entire geometry collection by now. I’ve tried everything in blueprints and can’t get it to work.

I too am looking for a BP-based solution.

After some tests and digging into source code, found possibility to change collision profile.

1 Like