Hit detection not working for second component in a Blueprint

EDIT: Ignore this – this is probably just a collision issue with the underlying static mesh. Will talk to our artist about it tomorrow.

We have a bit of hit-detection code that looks like this:

FHitResult Hit;
if( GetHitResultAtScreenPosition(mouse_pos, TraceTypeQuery1, true, Hit))
{
	SelectBuilding( Cast( Hit.Actor.Get() ) );
}

As you can see, this tries to trace a building at the mouse position.

One of our buildings looks like this: an air storage unit (composed of 4 cylindrical storage tanks) on top of a foundation piece.

componentsbug1.png

componentsbug2.png

However, we’re seeing that this mouse-picking function will select the AirStorageMesh just fine, but will NEVER pick the foundation tile – it will return the ground beneath it instead.

We’ve ruled out the obvious answers:

  • It’s not a problem with the collision properties of the components (in the Collision property category). Both the Foundation and AirStorageMesh have identical collision properties; both are set to Collision Presets = BlockAll and have the “Block” column checked for all their collision properties.
  • The Foundation mesh does have proper collision; we have another object that uses only that Foundation mesh and that one IS selectable with no problems.
  • The Foundation is well above the Ground geometry it’s sitting on top of, so the Ground itself should not be the problem.

How to investigate this?

Also, what the heck is TraceTypeQuery1? It seems to be totally undocumented, both in the documentation and the code.

This seems to be a bug with the collision for the static mesh. I’d thought the static mesh here was identical to the one whose collision was working properly, but it turns out it’s a different mesh.

I will bug our artist about this. In the meantime, please ignore this.

Dear Mothership,

What is this bulding? Is it a static mesh?

Try using ECollisionChannel instead of ETraceTypeQuery

GetHitResultAtScreenPosition(mouse_pos,ECC_WorldDynamic, true, Hit)

If that doesnt work:

If you review your question history, I gave you the complete code to use a mouse cursor in a way that would detect all subcomponents, at least it has worked for me that way :slight_smile:

http://forums.epicgames.com/threads/972861-Tutorial-Compile-C-for-UE4-Code-Samples-For-You-gt-gt-New-Get-Set-AnimBluePrint-Vars?p=31656285&viewfull=1#post31656285

Yes, I’ve tried it with ECC_WorldDynamic, too, as well as ECC_WorldStatic, but that doesn’t make a difference.

Also, I appreciate the attempt to help, but your code sample won’t work for me – it’s attempting to call LineTraceSingle from inside the HUD. I’m not calling this from inside my HUD, and I don’t have access to a Canvas, and I really want to know why GetHitResultAtScreenPosition() isn’t working as intended rather than trying to work around it by calling some other function.

What I’d still like to know:

what is your building?

Is it a static mesh?

what is derived from?

Rama

Yes, it’s a static mesh. Just the same as the other one. So it’s basically those two static mesh components, under a Scene component, inside a Blueprint which is our building. And that Blueprint class is derived from one of our custom C++ classes which is ultimately derived from AActor.