Is there a way in C++ to toggle the options (Ignore / Overlap / Block) for Trace Responses on an Actor?
The options I am talking about:
Select Actor, Details window, Physics tab, Collision Presets section and set the collision preset to Custom, you will be able to see the Trace Responses. These are used in LineTraceSingleByChannel().
What I have tried:
• I have tried looking for different commands/components by typing myActor-> and then key words like “trace”, “response”, “collision”, and “physics” but nothing seems to lead me to a component that would allow me to set these Trace Responses to an option. This seems to only be accessible through the editor and blueprints.
• I have read the documentation for ECollisionChannel hoping that it might list a way for the options to be accessed. It does not.
• I have tried to look for forum posts about this issue, but the few I found weren’t helpful.
Why set them at runtime?
For objects spawned through C++ at runtime, I need to be able to set these properties. Because they are only created at runtime, I cannot simply go into the editor to check or uncheck the options.
What is the ultimate goal here?
I was hoping to select NPCs and click clickable objects through a custom trace channel. This would allow only the objects using this channel to be considered in the LineTraceSingleByChannel(). Even though ECC_Visibility covers most cases, there will be cases like a clickable item on the ground being obstructed by grass or plants. The line trace would return the grass instead of the clickable item. This is why having all NPCs and clickable items on a single trace channel would be preferable.
My current work-around:
The trace accepts an FCollisionQueryParams whereby Actors can be added to AddIgnoredActors(). I would effectively add every conceivable Actor to this list, minus the NPCs and clickable items. I would rather not do this because the list would become very large and I would have to manage adding/removing objects as they are created/destroyed. It would be significantly less code to just be able to write myActor->GetCollisionThing->SetTraceChannelOption(ECC_GameTraceChannel1, “block”); in an object’s class.
Any ideas? Thanks.
Edit: I did just discover LineTraceMultiByChannel() to which I could sort through the results with a for loop and could set a tag of “clickable” and check for that, then proceed on with my code. This is another solution and probably the best. I would still like to know if there is a way to set the Trace Channel options though.
