GetHitResultUnderCursorByChannel bug with custom trace channel?

Hi,

I’m seeing unexpected behavior with EventActorOnClicked and GetHitResultUnderCursorByChannel when using a custom project trace (collision) channel and Instanced Static Meshes. From what I can tell, this might be a bug in the engine.

The setup is as follows:

  1. Create an Actor blueprint and add a InstancedStaticMesh Component to it which uses a single quad as a mesh (a map tile in my case).
  2. Create a custom trace (collision) channel in the project settings with Default Response Ignore.


3. Using Blueprint scripting, build a couple of Instanced Static Meshes with a For loop and assign them to Block on the custom channel.


4. Use a Player Controller with mouse input activated and use GetHitResultUnderCursorByChannel to test for collisions with the DefaultSceneRoot of the blueprint instance (i.e. the parent element of the mesh instances).


5. Trigger the test in step 4 using EventActorOnClicked.

Expected behavior:

Whenever I click any of the instanced meshes, EventActorOnClicked should fire and run GetHitResultUnderCursorByChannel which should have a Return Value of true, and I should then be able to obtain the Hit Actor and Location of the Hit. If the mouse is not over an instanced mesh when clicking, EventActorOnClicked should not fire.

Actual observed behavior:

Hit detection for all instances works correctly as expected except for the first InstancedStaticMesh that was created. For this first instance EventActorOnClicked fires but the Return Value of GetHitResultUnderCursorByChannel is false. Using HitActor then fails with the following error message:
PIE:Error: Error Accessed None 'CallFunc_BreakHitResult_HitActor' from node Return Node in graph 'MyBlueprintFunctionName' in blueprint Level

Can anyone confirm if this is a bug or point me to whatever I am missing?

Thanks.

Since this issue seems to still be an issue at least with 5.2, figured I’d give this my solution in case anyone else also runs into it.
While disabling and enabling the collision works, that may also break other responses momentarily, so I found this neat little method buried in there.

Edit: For a BP you’ll need to use a BlueprintFunctionLibrary per my other response here, but it still requires a C++ project. I don’t really have a solution if your project is BP only.

InstancedStaticMeshComponent* MeshInst;

// ...

for (FBodyInstance* body : MeshInst->InstanceBodies)
{
	body->CopyRuntimeBodyInstancePropertiesFrom(&MeshInst->BodyInstance);
}