Get coordinates of the point at which a camera is pointed at
#1

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.
Reply
#2

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.
Reply
#3

The only information that i have are the position of camera and its rotation. How i could do?
Reply
#4

Why you need those positions? Can you write more?
Reply
#5

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.
Reply
#6

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.
Reply
#7

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
Reply
#8

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)