Skip to main content

World Text

Namespace: DeadworksManaged.Api

Display text in the 3D world or anchored to a player's screen.

CPointWorldText

Wraps the point_worldtext entity — a world-space text panel rendered in 3D.

Creating World Text

var text = CPointWorldText.Create(
message: "Hello World",
position: new Vector3(100, 200, 300),
fontSize: 100f,
r: 255, g: 255, b: 255, a: 255, // RGBA color
worldUnitsPerPx: 0
);

Parameters

ParameterTypeDescription
messagestringText to display
positionVector3World-space position
fontSizefloatFont size in pixels
r, g, b, abyteRGBA color components
worldUnitsPerPxintWorld units per pixel (0 = default)

Updating Text

text.SetMessage("Updated text!");

Cleanup

text.Remove();  // Inherited from CBaseEntity

ScreenText

Displays world text anchored to a player's camera (screen-space). Internally uses a CPointWorldText entity parented to the player.

Camera Offset

Deadlock uses a right-shoulder third-person camera, positioned ~35 units to the right of the player's eye position. ScreenText positions are relative to the model eye, not the actual camera — so screen-center coordinates are not (0.5, 0.5).

Calibrated center position: posX: 2.341f, posY: 2.6f (these values are far beyond the 0-1 range due to the shoulder offset).

Positioning Tips

ParameterRecommended ValueNotes
fwdOffset-50fPlaces text close to camera (behind eye position)
posX2.341fHorizontal center (accounting for shoulder camera)
posY2.6fVertical center
PixelSize50fGood size for pixel art blocks
SpacingX0.023fHorizontal character spacing
SpacingY0.06fVertical character spacing (~2.6x taller than wide for "█")
Pixel Art

Use the full block character "█" for pixel-art style displays. The "." character is invisible at small sizes. The block character is approximately 2.6x taller than wide, so adjust SpacingX and SpacingY accordingly for square pixels.

Example: Toggle Screen Overlay

From the Deathmatch plugin:

private CPointWorldText? _screenText;

[ChatCommand("worldtext")]
public HookResult OnWorldText(ChatCommandContext ctx)
{
var pawn = ctx.Controller?.GetHeroPawn();
if (pawn == null) return HookResult.Handled;

if (_screenText != null)
{
_screenText.Remove();
_screenText = null;
return HookResult.Handled;
}

// Create text at screen center
_screenText = CPointWorldText.Create(
"OVERLAY TEXT",
pawn.EyePosition, // Will be parented to player
fontSize: 200f,
r: 255, g: 255, b: 255, a: 255
);

return HookResult.Handled;
}

See Also

  • Entities — Base entity operations (Remove, SetParent)
  • Networking — HUD announcements as an alternative