Is it possible to set two physics objects to not collide with eachother on spawn?

This question was created in reference to: [Is it possible to set two physics objects to not collide with [Content removed]

________________________________________________________________________________________________________________________________________________________________________

Hi there,

I am spawning an actor with Physics collision inside of another.

FChaosEngineInterface::AddDisabledCollisionsFor_AssumesLocked, as suggested in the referenced question, is (I assume) the “correct” way to disable collisions on a particle to particle basis.

However

That method has to be performed inside an asynchronous callback of FPhysicsCommand::ExecuteWrite, because the physics scene has to be locked before the operation can be processed.

This means that, in the case of spawning a particle within another, I have to adhere to the following sequence:

  1. Spawn Actor (Particle)
  2. Disable Physics Collision
  3. Lock Physics Thread
  4. Wait
    1. FChaosEngineInterface::AddDisabledCollisionsFor_AssumesLocked
    2. Enable Physics Collision
    3. Add Impulse
    4. etc.

The undesirable part of this sequence is having to wait for the callback before being able to do anything with the actor’s physics.

________________________________________________________________________________________________________________________________________________________________________

Is there a better way to implement my desired functionality?

What would you suggest?

Kind regards,

Josh

Hi,

One alternative I can think of is instead of disabling collisions post-spawn, is it possible for your workflow to instead configure the two to never collide in the first place using custom object channels?

For example, Object A has Custom Channel A, Object B has Custom Channel B - we can use SetCollisionResponseToChannel on Object A to Ignore Channel B.

That being said if you were wanting it to be more narrowed down to specific instances and not a broad channel, the wait to do anything with the actor’s physics may be bypassed if you spawn the actors with physics initially disabled.

Having it disabled on spawn would ensure that its physics don’t start until enabled and can have its settings configured.

Please let me know what you think!

Regards

Heya John,

Thank you so much for getting back to me!

Indeed - This is a situation where channel responses are not appropriate.

Ah I see! That sounds like a promising avenue! I’m unable to test this right now, but when I get back around to it I’ll give that a try.

Cheers,

Josh.