# Why is 'contacts.ignore' not take effect?

**URL:** <https://forums.unrealengine.com/t/why-is-contacts-ignore-not-take-effect/253290>\
**Category:** C++\
**Tags:** unreal-engine, UE4-27\
**Created:** [September 29, 2021, 2:16pm UTC](https://forums.unrealengine.com/t/why-is-contacts-ignore-not-take-effect/253290 "2021-09-29T14:16:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tancen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tancen](https://forums.unrealengine.com/u/tancen)\
**Post date:** [September 29, 2021, 2:16pm UTC](https://forums.unrealengine.com/t/why-is-contacts-ignore-not-take-effect/253290/1 "2021-09-29T14:16:19Z")

</div>

Hi, everyone!

I testing my custom collision filter through FContactModifyCallback. In my testing, The character added itself to the bomb’s filter list on the bomb be spawning. My contact modifies callback checking the filter list and ignore the contact if the character in the bomb’s filter list. This worked if the bomb hasn’t dropped on the ground. On the bomb dropped on the ground, The character’s location has been adjusting forced, And the character will not be able to walk through the bomb. How fix it? Thanks!

```auto
void onContactModify(PxContactModifyPair* const pairs, PxU32 count)
	{
		for (PxU32 i = 0; i < count; i++)
		{
			PxContactModifyPair& pair = pairs[i];
			for (PxU32 j = 0; j < pair.contacts.size(); j++)
			{
				const FBodyInstance* bodyInst1 = FPhysxUserData::Get<FBodyInstance>(pair.actor[0]->userData);
				if (!bodyInst1)
				{
					UE_LOG(LogTemp, Error, TEXT("!bodyInst1"))
					continue;
				}
				AActor* actor1 = bodyInst1->OwnerComponent->GetOwner();

				const FBodyInstance* bodyInst2 = FPhysxUserData::Get<FBodyInstance>(pair.actor[1]->userData);
				if (!bodyInst2)
				{
					UE_LOG(LogTemp, Error, TEXT("!bodyInst2"))
					continue;
				}
				AActor* actor2 = bodyInst2->OwnerComponent->GetOwner();

				assert(actor1 && actor2);

				ABombBase* bomb = nullptr;
				bomb = dynamic_cast<ABombBase*>(actor1);
				if (bomb != nullptr)
				{
					assert(dynamic_cast<Atest2Character*>(actor2));
					if (bomb->isCollisionIgnoreActor(actor2))
					{
						UE_LOG(LogTemp, Error, TEXT("isCollisionIgnoreActor1"))
						pair.contacts.ignore(j);
					}
				}
				else
				{
					bomb = dynamic_cast<ABombBase*>(actor2);
					if (bomb != nullptr)
					{
						assert(dynamic_cast<Atest2Character*>(actor1));
						if (bomb->isCollisionIgnoreActor(actor1))
						{
							UE_LOG(LogTemp, Error, TEXT("isCollisionIgnoreActor2"))
							pair.contacts.ignore(j);
						}
					}
				}
			}
		}
	}

```

 ![1](https://d3kjluh73b9h9o.cloudfront.net/original/3X/3/e/3e6b095b251ccddc934c822e77e4b2d591978195.jpeg)

---

<div class="post-metadata">

**Author:** ![Jambax](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jambax/32/904177_2.png) [@Jambax](https://forums.unrealengine.com/u/Jambax)\
**Post date:** [September 29, 2021, 3:40pm UTC](https://forums.unrealengine.com/t/why-is-contacts-ignore-not-take-effect/253290/2 "2021-09-29T15:40:14Z")

</div>

Unsure what you’re trying to do Contact Modifiers are an advanced feature and only suitable for objects simulating Physics, they can’t be used with characters since they are kinematic objects and do not generate contacts.

You also should never use dynamic\_cast in Unreal - use Cast\<\>. dynamic\_cast doesn’t work anyway, it’s redefined to Cast\<\>.

---

<div class="post-metadata">

**Author:** ![tancen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tancen](https://forums.unrealengine.com/u/tancen)\
**Post date:** [September 30, 2021, 4:38am UTC](https://forums.unrealengine.com/t/why-is-contacts-ignore-not-take-effect/253290/3 "2021-09-30T04:38:56Z")

</div>

Thanks, How do I customize advanced collision filtering for character ? In my project, I need to filter the collision if bombs created by the characters and clear the filter when the characters overlap end.

---

<div class="post-metadata">

**Author:** ![Jambax](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jambax/32/904177_2.png) [@Jambax](https://forums.unrealengine.com/u/Jambax)\
**Post date:** [September 30, 2021, 7:42am UTC](https://forums.unrealengine.com/t/why-is-contacts-ignore-not-take-effect/253290/4 "2021-09-30T07:42:20Z")

</div>

You can use MoveIgnoreActors (on both the bomb and character) to have them ignore each other, that’s common for projectiles.

You could then perform a collision query each tick until the bomb and character are no longer overlapping, then disable the MoveIgnoreActors behaviour. Most of the time a timer or something is sufficient though.

---

<div class="post-metadata">

**Author:** ![tancen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tancen](https://forums.unrealengine.com/u/tancen)\
**Post date:** [October 1, 2021, 3:33am UTC](https://forums.unrealengine.com/t/why-is-contacts-ignore-not-take-effect/253290/5 "2021-10-01T03:33:35Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![HappyHappyPlay](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HappyHappyPlay](https://forums.unrealengine.com/u/HappyHappyPlay)\
**Post date:** [April 5, 2022, 12:47pm UTC](https://forums.unrealengine.com/t/why-is-contacts-ignore-not-take-effect/253290/6 "2022-04-05T12:47:06Z")

</div>

For anyone running into this in the future, here is a link to @tancen 's own great answer! 🙂

> [@How do I get my ContactModifyCallback to work?](https://forums.unrealengine.com/t/how-do-i-get-my-contactmodifycallback-to-work/250909/5):
>
> Finally, I find a way to make it worked. // Fill out your copyright notice in the Description page of Project Settings. #pragma optimize("", off) #include "MyWorldSettings.h" #include \<PhysXPublicCore.h\> #include "Physics/PhysicsFiltering.h" PxFilterFlags PxSimulationFilterShaderProc(PxFilterObjectAttributes attributes0, PxFilterData filterData0, PxFilterObjectAttributes attributes1, PxFilterData filterData1, PxPairFlags& pairFlags, const void\* constantBlock, PxU32 constantBlockSize) { pa…
