In my game i have AI enemies who need to hide from the player at coverpoints, but these coverpoints need to be disabled when the player has a direct line of sight to them, i tried to stop the point from blocking line traces using this:
But it did not work, the AI enemies line traces still got blocked by the coverpoints. Because of this i am unsure how to stop an actor from blocking line traces. Here is also the blueprint the AI uses to find coverpoints.
You could use a custom trace channel and set the collision with the cover points to “Ignore”.
You can create custom trace channels in "Project Settings → Engine → Collision → Trace Channels → New Trace Channel. Make the default response “block”, then on every world object that shouldn’t block, update the collision to be ignored.
Clarification: You will not need to change any collision during runtime if you do this. The cover points will simply be ignored by every trace using this channel.
Oh I thought you had a different problem… (And just noticed you are already using a custom trace channel).
Why are you using line traces to determine distance instead of Distance(cover location, AI location)?
The problem is that the points need to be able to block line traces when the player does not see it BUT when the player sees the point it needs to not block line traces. That is why i need it to change in runtime.
So if I understand you correctly, you have floating collision boxes that AI can hide behind, but if the player has direct line of sight to it, the collision is disabled.
The above screenshot is the BP of the coverpoint (hence its name I guess). I think this is where your mistake lies.
The tick event fires for every coverpoint, so you don’t have to loop through all coverpoints, because it’s already doing that.
I’d just keep getting all AI ATTACKERs to ignore them in the trace, then make a single LineTrace (as the Tick is computed for every CoverPoint seperately) from GetActorLocation(self) towards the player and if it’s not blocked (direct line of sight) go on as you did.
If you want to make it in a loop (would only make sense if you did it in a seperate BP and not in the coverpoint itself) you’d need to make sure to access the collision component from the ArrayElement node of the loop. The way you did it only accesses with the local collision box. Basically, if your loop ends with an object that is not in line of sight, all the cover points will still block
Hope I understood this time and that I could help you with this.