Scripting/Client/Functions/Draw3DTextWorld
v0.4+ (PC and Android): text as a real quad in the 3D world - it has a position, a rotation and a size in metres, is hidden by walls and cars (depth test) and is not a 2D screen overlay. Call it every frame from onClientRender. Rotation is in degrees: rz = heading (like Player.Angle), rx = pitch, ry = roll; (0, 0, 0) stands the text upright with its front facing -Y (readable from the south). Size: one line is about 0.55 m tall times scaleY (width follows the text, times scaleX); \n starts a new line (up to 8). distance > 0 hides it beyond that range with a fade (nothing is drawn beyond 400 m). colour is a Colour or 0xAARRGGBB; the text gets a black outline. Visible from both sides (mirrored from behind). Max 256 world quads per frame.
Syntax
Draw3DTextWorld(text, x, y, z, rx, ry, rz [, scaleX [, scaleY [, distance [, colour]]]])Draw3DTextWorld(text, Vector pos, Vector rot [, scaleX ...])Arguments
- string text
- float x
- float y
- float z
- float rx – Rotation is in degrees:
rz= heading (likePlayer.Angle),rx= pitch,ry= roll; (0, 0, 0) stands the text upright with its front facing -Y (readable from the south). - float ry – Rotation is in degrees:
rz= heading (likePlayer.Angle),rx= pitch,ry= roll; (0, 0, 0) stands the text upright with its front facing -Y (readable from the south). - float rz – Rotation is in degrees:
rz= heading (likePlayer.Angle),rx= pitch,ry= roll; (0, 0, 0) stands the text upright with its front facing -Y (readable from the south). - any scaleX (optional) – Size: one line is about 0.55 m tall times
scaleY(width follows the text, timesscaleX);\nstarts a new line (up to 8). - any scaleY (optional) – Size: one line is about 0.55 m tall times
scaleY(width follows the text, timesscaleX);\nstarts a new line (up to 8). - float distance (optional) –
distance> 0 hides it beyond that range with a fade (nothing is drawn beyond 400 m). - Colour colour (optional) –
colouris aColouror 0xAARRGGBB; the text gets a black outline. - Vector pos
- Vector rot
- any scaleX ... (optional)
Returns
bool
Example
function onScriptLoad()
{
local pos = player.Pos;
local result = Draw3DTextWorld( "Hello world", pos.x, pos.y, pos.z, 0.0, 0.0, 0.0 );
MessagePlayer( "Draw3DTextWorld returned: " + result, player );
}This sample was generated from the signature – adapt the values to your gamemode.
Related pages
- GetScreenWidth
- WorldPosToScreen
- ScreenPosToWorld
- GetGroundZLevel
- GetGroundZLevelForPos
- GetGroundZLevelForPosLoad
- Draw3DText
- Draw3DSprite
- Draw3DSpriteWorld
- SetCameraMatrix
- SetCameraTarget
- RestoreCamera
Section: Screen, world and camera