Get coordinates of the point at which a camera is pointed at -
pollo97 - 25.10.2017
I'm setting up a CCTV system for my users and I ran into a problem.
Is there a way to get the coordinates of the point at which a camera is pointing at? I need them to set the angle of the player's POV when he gets into camera mode, which is wrong by default.
Re: Get coordinates of the point at which a camera is pointed at -
Danisoni - 25.10.2017
Well try to get player's camera looking angle, use sin/cos with degrees, use high number, and try to combine it with CA_RayCastLine (ColAndreas Function) to get closest X,Y,Z.
Re: Get coordinates of the point at which a camera is pointed at -
pollo97 - 25.10.2017
The only information that i have are the position of camera and its rotation. How i could do?
Re: Get coordinates of the point at which a camera is pointed at -
Amagida - 25.10.2017
Why you need those positions? Can you write more?
Re: Get coordinates of the point at which a camera is pointed at -
pollo97 - 26.10.2017
The information i need is the point (x,y,z) that camera is looking when it has a certain rotation (rx,ry,rz).
This is for set correctly the playercameralookat when a player enter in camera mode.
Re: Get coordinates of the point at which a camera is pointed at -
NaS - 26.10.2017
Convert it to a vector and add that vector to the camera position:
Код:
// Assume rx, ry, rz hold the rotation in degrees, x, y, z is the position and range is the distance
new Float:px = x - range * floatcos(rx, degrees) * floatsin(rz, degrees);
new Float:py = y + range * floatcos(rx, degrees) * floatcos(rz, degrees);
new Float:pz = z + range * floatsin(rx, degrees);
px, py, pz will then be the new position with the defined distance from the camera position.
You actually only need rx and rz since the camera cannot be rotated on the Y axis anyway.
If you need to find an actual collision point the camera is pointing at, use a high distance (300 should be sufficient), and raycast between both points.
Re: Get coordinates of the point at which a camera is pointed at -
DeStRoY232 - 26.10.2017
use this
https://sampforum.blast.hk/showthread.php?tid=282801
just point the camera where u want it to be and click
Copy CameraLookAt() Coords
and then press CTRL + V and u will get your coords
Re: Get coordinates of the point at which a camera is pointed at -
pollo97 - 27.10.2017
Quote:
Originally Posted by NaS
Convert it to a vector and add that vector to the camera position:
Код:
// Assume rx, ry, rz hold the rotation in degrees, x, y, z is the position and range is the distance
new Float:px = x - range * floatcos(rx, degrees) * floatsin(rz, degrees);
new Float:py = y + range * floatcos(rx, degrees) * floatcos(rz, degrees);
new Float:pz = z + range * floatsin(rx, degrees);
px, py, pz will then be the new position with the defined distance from the camera position.
You actually only need rx and rz since the camera cannot be rotated on the Y axis anyway.
If you need to find an actual collision point the camera is pointing at, use a high distance (300 should be sufficient), and raycast between both points.
|
This works perfect

Thank you.