GetPlayerCameraFrontVector question
#1

Hi, I need GetPlayerCameraFrontVector to get the aim target x,y,z.
but camera rotation is not like aim.

whatever, the question is:

pawn Код:
// A simple command to manipulate this vector using the
// positions from GetPlayerCameraPos. This command will create
// a hydra missile in the direction of where the player is looking.
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp(cmdtext, "/test camera vector"))
    {
        new
            Float:fPX, Float:fPY, Float:fPZ,
            Float:fVX, Float:fVY, Float:fVZ,
            Float:object_x, Float:object_y, Float:object_z;
 
        // Change me to change the scale you want. A larger scale increases the distance from the camera.
        // A negative scale will inverse the vectors and make them face in the opposite direction.
        const
            Float:fScale = 5.0;
 
        GetPlayerCameraPos(playerid, fPX, fPY, fPZ);
        GetPlayerCameraFrontVector(playerid, fVX, fVY, fVZ);
 
        object_x = fPX + floatmul(fVX, fScale);
        object_y = fPY + floatmul(fVY, fScale);
        object_z = fPZ + floatmul(fVZ, fScale);
 
        CreateObject(345, object_x, object_y, object_z, 0.0, 0.0, 0.0);
 
        return 1;
    }
 
    return 0;
}
this is from wiki, so

pawn Код:
object_x = fPX + floatmul(fVX, fScale);
is from circumference of a circle formula

x = ox + radius * cos(angle)
y = oy + radius * sin(angle)


so.. FVX should be cos of angle?
and how i get z angle? cuz i don't know formula for circumference of a sphere

if I'm wrong, somebody can explain me what are these vectors?
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=591010

PHP код:
GetPlayerCameraRotation(playerid,&Float:rx,&Float:rz); 
GetPointInFrontOfCamera3D(playerid,&Float:tx,&Float:ty,&Float:tz,Float:radius,&Float:rx=0.0,&Float:rz=0.0); 
Reply
#3

Question?, the code you gave us, isn't it working like it should?
It should create an object 5 meter in the direction you are looking at

And if you want the direction of your weapon, that is only possible with approximation
Reply
#4

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
Question?, the code you gave us, isn't it working like it should?
It should create an object 5 meter in the direction you are looking at

And if you want the direction of your weapon, that is only possible with approximation
u should learn english, maybe, i know u want to increase your posts, but is better for you, trust me

Quote:
Originally Posted by AbyssMorgan
Посмотреть сообщение
https://sampforum.blast.hk/showthread.php?tid=591010

PHP код:
GetPlayerCameraRotation(playerid,&Float:rx,&Float:rz); 
GetPointInFrontOfCamera3D(playerid,&Float:tx,&Float:ty,&Float:tz,Float:radius,&Float:rx=0.0,&Float:rz=0.0); 
thanks mate.
Reply
#5

What do you want it for? If it's like for detecting if a player is aiming at an actor (there's also a function for players), you can use https://sampwiki.blast.hk/wiki/GetPlayerTargetActor.

The code on the wiki creates an object at the position of your crosshair.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)