codeAPI Reference

SceneTraceResult: All Fields and Properties from Trace Hits

calendar_today May 20, 2026 schedule ~1 min read person PatrickJr verified 50
SceneTraceResult is returned by Scene.Trace..Run() and contains all information about a trace hit.

Key Fields

CSHARP
SceneTraceResult tr = Scene.Trace.Ray( start, end ).Run();

tr.Hit           // bool — whether the trace hit something
tr.StartedSolid  // bool — whether trace started inside a solid
tr.StartPosition // Vector3 — start of the trace
tr.EndPosition   // Vector3 — end or hit position
tr.HitPosition   // Vector3 — precise hit position (requires UseHitPosition)
tr.Normal        // Vector3 — hit surface normal direction
tr.Fraction      // float [0..1] — where between start and end the hit occurred
tr.Distance      // float — distance between start and end positions
tr.Direction     // Vector3 — direction of the trace ray

tr.GameObject    // GameObject that was hit
tr.Component     // Component that was hit
tr.Collider      // Collider that was hit
tr.Body          // PhysicsBody that was hit
tr.Shape         // PhysicsShape that was hit
tr.Surface       // Surface — physical properties of hit surface
tr.Bone          // int — hit bone ID (from hitbox or physics shape)
tr.Triangle      // int — triangle index if mesh shape was hit
tr.Tags          // string[] — tags on the hit shape
tr.Hitbox        // Hitbox — the hitbox that was hit

Common Usage Pattern

CSHARP
var tr = Scene.Trace
    .Ray( EyePosition, EyePosition + LookDirection * 5000f )
    .WithoutTags( "player" )
    .UseHitboxes( true )
    .Run();

if ( tr.Hit )
{
    Log.Info( $"Hit {tr.GameObject.Name} at {tr.EndPosition}" );
    Log.Info( $"Surface: {tr.Surface.ResourceName}" );
    Log.Info( $"Distance: {tr.Distance}" );

    var damageable = tr.GameObject.Components.Get<IDamageable>();
    if ( damageable != null )
    {
        damageable.OnDamage( new DamageInfo
        {
            Damage = 25f,
            Position = tr.EndPosition,
            Attacker = GameObject
        } );
    }
}
Was this helpful?