# OnHit Result PhysMat

**URL:** <https://forums.unrealengine.com/t/onhit-result-physmat/373578>\
**Category:** Rendering\
**Tags:** Trace, hit-result, unreal-engine, Landscape, question\
**Created:** [October 17, 2016, 1:27pm UTC](https://forums.unrealengine.com/t/onhit-result-physmat/373578 "2016-10-17T13:27:57Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kurosu143](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kurosu143](https://forums.unrealengine.com/u/kurosu143)\
**Post date:** [October 17, 2016, 1:27pm UTC](https://forums.unrealengine.com/t/onhit-result-physmat/373578/1 "2016-10-17T13:27:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_61b4a355](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_61b4a355](https://forums.unrealengine.com/u/anonymous_user_61b4a355)\
**Post date:** [October 17, 2016, 7:16pm UTC](https://forums.unrealengine.com/t/onhit-result-physmat/373578/2 "2016-10-17T19:16:33Z")

</div>

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”:

 ![111277-508230_col.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/c/1/bc12a36804cfa8b7c7ab836a752f743a3051055b.png)

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.

---

<div class="post-metadata">

**Author:** ![kurosu143](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kurosu143](https://forums.unrealengine.com/u/kurosu143)\
**Post date:** [October 18, 2016, 1:29am UTC](https://forums.unrealengine.com/t/onhit-result-physmat/373578/3 "2016-10-18T01:29:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_61b4a355](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_61b4a355](https://forums.unrealengine.com/u/anonymous_user_61b4a355)\
**Post date:** [October 18, 2016, 12:55pm UTC](https://forums.unrealengine.com/t/onhit-result-physmat/373578/4 "2016-10-18T12:55:36Z")

</div>

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

 ![111390-508230_phys.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/1/8/f18b0568b2a0e4d63fac3040a507a9aee6bad70a.png)

---

<div class="post-metadata">

**Author:** ![kurosu143](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kurosu143](https://forums.unrealengine.com/u/kurosu143)\
**Post date:** [October 18, 2016, 2:58pm UTC](https://forums.unrealengine.com/t/onhit-result-physmat/373578/5 "2016-10-18T14:58:15Z")

</div>

![111411-physmat.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/6/1/b611b56da5aac1e0c88bf3874c40534cdb673dcf.png)

Here’s what I’m getting

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_61b4a355](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_61b4a355](https://forums.unrealengine.com/u/anonymous_user_61b4a355)\
**Post date:** [October 18, 2016, 3:03pm UTC](https://forums.unrealengine.com/t/onhit-result-physmat/373578/6 "2016-10-18T15:03:55Z")

</div>

DefaultPhysicalMaterial is the PhysMaterial returning from Hit.

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_61b4a355](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_61b4a355](https://forums.unrealengine.com/u/anonymous_user_61b4a355)\
**Post date:** [October 18, 2016, 3:05pm UTC](https://forums.unrealengine.com/t/onhit-result-physmat/373578/7 "2016-10-18T15:05:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kurosu143](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kurosu143](https://forums.unrealengine.com/u/kurosu143)\
**Post date:** [October 18, 2016, 4:08pm UTC](https://forums.unrealengine.com/t/onhit-result-physmat/373578/8 "2016-10-18T16:08:34Z")

</div>

Yes, but from the one you showed me, it’s returning PhysMat\_Ice

---

<div class="post-metadata">

**Author:** ![kurosu143](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kurosu143](https://forums.unrealengine.com/u/kurosu143)\
**Post date:** [October 18, 2016, 4:23pm UTC](https://forums.unrealengine.com/t/onhit-result-physmat/373578/9 "2016-10-18T16:23:45Z")

</div>

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.
