Repository navigation
A3D_GetPlayerTarget
imshooter edited this page Oct 17, 2026
·
1 revision
Find what a player looks at, from their camera.
Reads the camera the client last sent. The player and the vehicle they are in are never hit.
native bool:A3D_GetPlayerTarget(
playerid,
&Float:x,
&Float:y,
&Float:z,
&A3D_HIT:type = A3D_HIT_MAP,
&hitid = 0,
&material = 0,
Float:range = 100.0,
A3D_COLLIDE:flags = A3D_COLLIDE_ALL
);| Parameter | Description | Default |
|---|---|---|
playerid |
Player who looks. | |
&Float:x |
Point looked at on the X axis. | |
&Float:y |
Point looked at on the Y axis. | |
&Float:z |
Point looked at on the Z axis. | |
&A3D_HIT:type |
What is looked at. | A3D_HIT_MAP |
&hitid |
Model of the map object, or the physics object, static object, player, vehicle or actor looked at. | 0 |
&material |
Surface of the game looked at, see A3D_GetMaterialName. |
0 |
Float:range |
How far to look. | 100.0 |
A3D_COLLIDE:flags |
What may be looked at. | A3D_COLLIDE_ALL |
-
truewhen something is looked at withinrange. -
falsewhen nothing, or the player is not connected or sent no camera yet.
The ray starts at the camera of the player and follows its direction, as the client last sent them. The player and the vehicle they are in are never hit, so a camera behind the player looks past them.
The client sends its camera while on foot. Bots of the NPC component send none, and a player who has just spawned may not have sent one yet. Both return false. The screen explains where the camera data comes from.
Shoves the physics object a player looks at, when it is near.
public OnPlayerKeyStateChange(playerid, KEY:newkeys, KEY:oldkeys) {
if (!(newkeys & KEY_YES)) {
return 1;
}
new
Float:x,
Float:y,
Float:z,
A3D_HIT:type,
hitid,
material
;
if (!A3D_GetPlayerTarget(playerid, x, y, z, type, hitid, material, 4.0)) {
return 1;
}
if (type != A3D_HIT_OBJECT) {
return 1;
}
A3D_ApplyImpulse(Physic:hitid, 0.0, 0.0, 30.0);
return 1;
}- 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_RayCast: Find the first thing a segment between two points hits.
- 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