Repository navigation
A3D_ScreenToWorld
imshooter edited this page Oct 17, 2026
·
1 revision
Find the direction a point of the screen of a player looks into, from the position of their camera.
native bool:A3D_ScreenToWorld(
playerid,
Float:screenX,
Float:screenY,
&Float:directionX,
&Float:directionY,
&Float:directionZ
);| Parameter | Description |
|---|---|
playerid |
Player whose screen it is. |
Float:screenX |
Point across the screen. |
Float:screenY |
Point down the screen. |
&Float:directionX |
Direction on the X axis, one metre long. |
&Float:directionY |
Direction on the Y axis. |
&Float:directionZ |
Direction on the Z axis. |
-
truewhen the direction was written. -
falsewhen the player sent no camera yet.
The direction starts at the camera of the player, which GetPlayerCameraPos gives. The centre of the screen, 320.0 and 224.0, gives the direction the camera looks in. A point outside the screen gives a direction outside the view.
A3D_GetScreenTarget follows the direction to what it meets. This native gives the direction for other uses, such as a sweep or a throw.
Throws a ball towards a point of the screen.
stock ThrowTowards(playerid, Float:screenX, Float:screenY) {
new
Float:x,
Float:y,
Float:z,
Float:directionX,
Float:directionY,
Float:directionZ,
Physic:ball
;
if (!A3D_ScreenToWorld(playerid, screenX, screenY, directionX, directionY, directionZ)) {
return;
}
GetPlayerPos(playerid, x, y, z);
ball = A3D_CreateSphere(1598, 0.3, x + directionX, y + directionY, z + 0.6, 0.5, GetPlayerVirtualWorld(playerid));
A3D_SetVelocity(ball, directionX * 15.0, directionY * 15.0, directionZ * 15.0);
}- A3D_GetScreenTarget: Find what a point of the screen of a player shows, such as the place they clicked on a grid of text draws.
- A3D_WorldToScreen: Find where a point of the world shows on the screen of a player.
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