OnHit Result PhysMat

OnHit Event hit result does not return any PhysMat of the material hit. Even if the bool on the actor for sending PhysMat info is true. Line trace returns the PhysMat of the actor material but not the landscape. I tried changing the landscape default PhysMat and the landscape material PhysMat and it’s still won’t work. I tried trace complex too and it’s still the same.

Hey kurosu143,

This is working for me:

Constructor:

CollisionComp->bReturnMaterialOnMove = true;

OnHit

void AAH508230Projectile::OnHit(UPrimitiveComponent* HitComp, 
                                AActor* OtherActor, 
                                UPrimitiveComponent* OtherComp, 
                                FVector NormalImpulse, 
                                const FHitResult& Hit)
{
	UPhysicalMaterial* HitPhysMat = Hit.PhysMaterial.Get();
	if( HitPhysMat )
	{
		UE_LOG( LogTemp, Warning, TEXT("%s"), *HitPhysMat->GetName( ) );
	}
    // Only add impulse and destroy projectile if we hit a physics
	if ((OtherActor != NULL) && (OtherActor != this) && (OtherComp != NULL) && OtherComp->IsSimulatingPhysics())
	{
		OtherComp->AddImpulseAtLocation(GetVelocity() * 100.0f, GetActorLocation());

		Destroy();
	}
}

If you are using Blueprint, change the CollisionComponent, in “Collision”:

Resulting in:

LogTemp:Warning: PinkPhysMat
LogTemp:Warning: BluePhysMat
LogTemp:Warning: BluePhysMat
LogTemp:Warning: BluePhysMat
LogTemp:Warning: DefaultPhysicalMaterial
LogTemp:Warning: BluePhysMat
LogTemp:Warning: BluePhysMat
LogTemp:Warning: BluePhysMat
LogTemp:Warning: DefaultPhysicalMaterial
LogTemp:Warning: BluePhysMat
LogTemp:Warning: RedPhysMat
LogTemp:Warning: BluePhysMat
LogTemp:Warning: BluePhysMat
LogTemp:Warning: BluePhysMat
LogTemp:Warning: BluePhysMat
LogTemp:Warning: BluePhysMat

Can you provide anymore information on your issue?

Thanks.

link text

Yep, I forgot to turn on bReturnMaterialOnMove for the projectile. Now it’s giving me the PhysMat of the actor, thanks for that. But the landscape still doesn’t. Here’s a project file.

I am not sure what you’re seeing but I just opened your project and got this as a result:

Here’s what I’m getting

DefaultPhysicalMaterial is the PhysMaterial returning from Hit.

I don’t understand the issue as the Physical Material is clearly being returned for you.

Hey kurosu143,

Thank you for submitting a bug report, however at this time we believe that the issue you are describing is not actually a bug with the Unreal Engine, and so we are not able to take any further action on this. If you still believe this may be a bug, please provide steps for us to reproduce the issue, and we will continue our investigation.

Yes, but from the one you showed me, it’s returning PhysMat_Ice

I found the problem, unsculpted landscape doesn’t return it.
At least if the sculpt is far away from the hit or not sculpted at all. I’m not sure why it doesn’t happen on yours though.