S&box Wiki

Cheat Sheet

A lot of things are common between game engines. Here's how to do a bunch of common stuff.

Console Printing

Log.Info( "It worked!" ); Log.Warning( $"{playername} is an idiot!" ); Log.Error( "Error!" );

Debug Drawing

// draw text at transform Gizmo.Draw.WorldText( "Some Text!", Transform.World ); // draw a line Gizmo.Draw.Line( startPos, endPos ); // draw text on screen Gizmo.Draw.ScreenText("Text but \non screen",Vector2.Zero);

Do a ray trace

// trace 2000 units in eye direction, ignore all entities TraceResult tr = Scene.Trace.Ray( AimRay, 2000 ) .Run(); // If we hit, draw a sphere if ( tr.Hit ) { Gizmo.Draw.SolidSphere( tr.HitPosition, 10.0f ); }