UnrealSharp
  • Home
  • FAQ
  • Getting Started
    • Setup
    • Your First Script
    • Debugging
    • Packaging
  • Documentation
    • Classes
      • Properties
        • C++ Functions As C# Properties
        • C++ Properties with Getters/Setters
      • Functions
        • Flags
        • MetaData
      • Default Actor Components
      • Helper Methods
    • Structs
    • Enums
    • Interfaces
    • Delegates
    • Collections
      • TArray
      • TNativeArray
      • TSet
      • TMap
    • Multiplayer
      • Replicated Properties
      • RPCs (Remote Procedure Calls)
      • Replicated UObjects
    • Primary Data Assets
      • Loading Primary Data Assets
    • Loading Soft References
    • Trace Channels
    • Static Variables
      • FWorldStaticVar<T>
      • FGameStaticVar<T>
    • Logging
    • Async
    • Gameplay Tags
      • Gameplay Tag Container
    • Extension / Mixin Methods
    • Subsystems
    • Module Lifecycle
  • Links
    • Github Repository
    • Roadmap
    • Discord
Powered by GitBook
On this page
  • ETraceChannel
  • ETraceChannel to ETraceTypeQuery
  1. Documentation

Trace Channels

Working with collision channels in C# is not great, as the engine internally uses ECollisionChannel mapped to ETraceTypeQuery for BP-exposed tracing functions like LineTraceByChannel and others. By default, these mappings are not intuitive in C#, as they are just numeric IDs, with no info about the collision channel name.

To bridge this gap, the ETraceChannel provide a way to work with more readable and user-defined channel names in C#.

ETraceChannel

The ETraceChannel enum defines a set of collision channels, each of which maps to a corresponding entry in the project's collision settings.

public enum ETraceChannel
{
    Visibility = 0,      // Default engine-provided channel
    Camera = 1,          // Default engine-provided channel
    MyOtherChannel = 2,  // User-defined collision channel
}

Note: The entries in ETraceChannel will regenerate whenever new collision channels are added or existing ones are modified in the Unreal Editor. Removing entries requires an engine restart, as it's an engine bug that they keep the removed channel around.

ETraceChannel to ETraceTypeQuery

Here's how to use the ETraceChannel enum and the ToQuery to use it with ETraceTypeQuery:

ETraceTypeQuery traceChannel = ETraceChannel.Camera.ToQuery();
SystemLibrary.LineTraceByChannel(this, start, end, traceChannel, false, actors, EDrawDebugTrace.None, out FHitResult hit, true);
PreviousLoading Soft ReferencesNextStatic Variables

Last updated 6 months ago