Ignore current collision inside OnHit

Hi!
Is it possible to “ignore” current collision inside OnHit function?
So the actor would pass through the collision without being blocked but at that moment.

MyCollider->OnComponentHit.AddUniqueDynamic(this, &AMyActor::OnHit);

void AMyActor::OnHit(UPrimitiveComponent* HitComp, AActor* Other, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
	// Do not block "Other" at this time.
	if (Other)
	{
		// Skip collision.
	}
	
	// I tried with the functions below but they don't work because they always block the first time:
	MyCollider->SetCollisionResponseToChannel("MyChannel", ECR_Ignore);
	HitComp->IgnoreActorWhenMoving(Other, true);
}

Thank you!

Hello,

If you set the collision response inside OnHit, I think it will be too late because It already hitted first If I’m not mistaken.

What is your object that HIT the actor? I think it’s better to give an example so we can imagine it better.

But for example, if you want a bullet to pass through your cube, then why don’t you set the bullet collision to Overlap / Query only from the first time?

Thank you for your help!
I’m trying to make an angle dependent collision, either the characters collide or the collision is ignored.
I saw some videos with Overlaps and other ways to do it but I’m trying in a “cleaner” way, as OnComponentHit already gives me the information I 'd just need to ignore the collision depending on the angle.

Ah I see, I don’t have an Idea about that sorry

1 Like