# LineTraceSingleByObjectType does not return a physics material in its FHitResult

**URL:** <https://forums.unrealengine.com/t/linetracesinglebyobjecttype-does-not-return-a-physics-material-in-its-fhitresult/350744>\
**Category:** World Creation\
**Tags:** Raycast, bug, unreal-engine, question, CPP\
**Created:** [March 16, 2016, 7:08pm UTC](https://forums.unrealengine.com/t/linetracesinglebyobjecttype-does-not-return-a-physics-material-in-its-fhitresult/350744 "2016-03-16T19:08:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![janimationd](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@janimationd](https://forums.unrealengine.com/u/janimationd)\
**Post date:** [March 16, 2016, 7:08pm UTC](https://forums.unrealengine.com/t/linetracesinglebyobjecttype-does-not-return-a-physics-material-in-its-fhitresult/350744/1 "2016-03-16T19:08:25Z")

</div>

Hi,

I’m trying to get information about the hit object’s physics material out of a LineTraceSingleByObjectType() trace.

The object definitely has a physics material assigned to it, and I’ve assured that this object is being hit by the raytrace, but in the FHitResult the physics material reference is invalid. (myHitResult.PhysMaterial.IsValid() is false)

I am able to reproduce this in a brand new project. Also, this only fails when performing raytraces in C++. In blueprints they work fine and return the correct Physics materials.

How can I get the physics material out of the ray trace?

---

<div class="post-metadata">

**Author:** ![janimationd](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@janimationd](https://forums.unrealengine.com/u/janimationd)\
**Post date:** [March 21, 2016, 8:21pm UTC](https://forums.unrealengine.com/t/linetracesinglebyobjecttype-does-not-return-a-physics-material-in-its-fhitresult/350744/2 "2016-03-21T20:21:46Z")

</div>

Is this intended behavior? Is this a bug? Am I doing something wrong?

---

<div class="post-metadata">

**Author:** ![janimationd](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@janimationd](https://forums.unrealengine.com/u/janimationd)\
**Post date:** [March 22, 2016, 5:08pm UTC](https://forums.unrealengine.com/t/linetracesinglebyobjecttype-does-not-return-a-physics-material-in-its-fhitresult/350744/3 "2016-03-22T17:08:37Z")

</div>

I **am** able to reproduce this issue in a brand new project. If I use line traces through blueprints, the hit result in the blueprint has a valid physics material, but not when I perform line traces in c++.

---

<div class="post-metadata">

**Author:** ![Sean\_Flint](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sean\_Flint](https://forums.unrealengine.com/u/Sean_Flint)\
**Post date:** [March 22, 2016, 5:15pm UTC](https://forums.unrealengine.com/t/linetracesinglebyobjecttype-does-not-return-a-physics-material-in-its-fhitresult/350744/4 "2016-03-22T17:15:36Z")

</div>

Hello,

I apologize for the delay. Since you’ve been able to reproduce the issue in a clean project, could you zip up that project and provide it? I have also confirmed that it works in blueprints.

---

<div class="post-metadata">

**Author:** ![janimationd](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@janimationd](https://forums.unrealengine.com/u/janimationd)\
**Post date:** [March 22, 2016, 5:34pm UTC](https://forums.unrealengine.com/t/linetracesinglebyobjecttype-does-not-return-a-physics-material-in-its-fhitresult/350744/5 "2016-03-22T17:34:18Z")

</div>

Sure, here’s a link to the project download:

> **[Meet Google Drive – One place for all your files](https://accounts.google.com/ServiceLogin?service=wise&passive=1209600&continue=https:%2F%2Fdrive.google.com%2Ffile%2Fd%2F0B8udAKlj0SSVSUp5ejBrSFlXOVE%2Fview?usp%3Dsharing&followup=https:%2F%2Fdrive.google.com%2Ffile%2Fd%2F0B8udAKlj0SSVSUp5ejBrSFlXOVE%2Fview?usp%3Dsharing)**
>
> Google Drive is a free way to keep your files backed up and easy to reach from any phone, tablet, or computer. Start with 15GB of Google storage – free.

Move the red cube towards and away from the cylinder and watch the output log. I’m performing a line trace of length 250 form the center of the red cube towards the cylinder. You can see in my C++ code class “MyActor::tick()” where I’m printing the messages.

---

<div class="post-metadata">

**Author:** ![Sean\_Flint](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sean\_Flint](https://forums.unrealengine.com/u/Sean_Flint)\
**Post date:** [March 22, 2016, 6:20pm UTC](https://forums.unrealengine.com/t/linetracesinglebyobjecttype-does-not-return-a-physics-material-in-its-fhitresult/350744/6 "2016-03-22T18:20:58Z")

</div>

Hello,

I have been able to reproduce your issue, and have entered a bug report (UE-28640). Thank you for providing the test project. I will provide updates on this issue as they become available.

Have a great day

---

<div class="post-metadata">

**Author:** ![Dig\_Squid](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dig_squid/32/1145423_2.png) [@Dig\_Squid](https://forums.unrealengine.com/u/Dig_Squid)\
**Post date:** [March 23, 2016, 11:22am UTC](https://forums.unrealengine.com/t/linetracesinglebyobjecttype-does-not-return-a-physics-material-in-its-fhitresult/350744/7 "2016-03-23T11:22:44Z")

</div>

Have you made sure to set the bReturnPhysicalMaterial flag on the FCollisionQueryParams passed to the function? This defaults to true for BP traces, but is left to the caller for C++ users, as it is considered a slightly more advanced API.

---

<div class="post-metadata">

**Author:** ![janimationd](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@janimationd](https://forums.unrealengine.com/u/janimationd)\
**Post date:** [March 23, 2016, 4:27pm UTC](https://forums.unrealengine.com/t/linetracesinglebyobjecttype-does-not-return-a-physics-material-in-its-fhitresult/350744/8 "2016-03-23T16:27:46Z")

</div>

I was not aware that such a flag was available in the QueryParams. Thanks!
