Repository navigation
A3D_WorldToScreen
imshooter edited this page Oct 17, 2026
·
1 revision
Find where a point of the world shows on the screen of a player.
A point beside the screen gets coordinates beyond it.
native bool:A3D_WorldToScreen(playerid, Float:x, Float:y, Float:z, &Float:screenX, &Float:screenY);| Parameter | Description |
|---|---|
playerid |
Player whose screen it is. |
Float:x |
Point on the X axis. |
Float:y |
Point on the Y axis. |
Float:z |
Point on the Z axis. |
&Float:screenX |
Where it shows across the screen. |
&Float:screenY |
Where it shows down the screen. |
-
truewhen the point lies in front of the camera. -
falsewhen it lies behind it, or the player sent no camera yet.
The coordinates are those of text draws: 640 units across and 448 down, from the top left corner, whatever the resolution of the player. The screen explains how they are worked out from the camera the client sends.
A point beside or above the screen gets coordinates beyond it, which lets an arrow at the edge point to it. A point behind the camera gets none and the native returns false. Nothing is tested in between, so the point may be hidden by a wall. A3D_IsPointOnScreen can test that.
Keeps a mark over a vehicle on the screen of a player.
static PlayerText:gMark[MAX_PLAYERS] = { INVALID_PLAYER_TEXT_DRAW, ... };
forward @Mark_Update(playerid, vehicleid);
public @Mark_Update(playerid, vehicleid) {
new
Float:x,
Float:y,
Float:z,
Float:screenX,
Float:screenY
;
GetVehiclePos(vehicleid, x, y, z);
if (!A3D_WorldToScreen(playerid, x, y, z + 1.5, screenX, screenY)) {
PlayerTextDrawHide(playerid, gMark[playerid]);
return 1;
}
PlayerTextDrawSetPos(playerid, gMark[playerid], screenX, screenY);
PlayerTextDrawShow(playerid, gMark[playerid]);
return 1;
}
stock MarkVehicle(playerid, vehicleid) {
gMark[playerid] = CreatePlayerTextDraw(playerid, 0.0, 0.0, "V");
SetTimerEx("@Mark_Update", 100, true, "ii", playerid, vehicleid);
}- A3D_ScreenToWorld: Find the direction a point of the screen of a player looks into, from the position of their camera.
- A3D_IsPointOnScreen: Whether a point shows on the screen of a player.
- A3D_GetPlayersOnScreen: Find the players on the screen of a player, nearest first, in the same virtual world and interior.
3DAndreas 0.7.1 · Repository · Releases · MIT License
Guides
- Installation
- Configuration
- Physics objects
- Model settings
- World queries
- The screen
- Routes
- Navigation mesh
- Map database
- Coming from ColAndreas
- Performance
Reference
Functions