Getting Player's Camera Look At
#4

Thanks samgreen, I do need some assistance with it.
I'm trying to check if the player is looking at some point, and do something if he does.

This is the code:

pawn Код:
stock IsPlayerLookingAtFire(playerid, fireid)
{
    new
        Float:cX, Float:cY, Float:cZ,
        Float:cPosX, Float:cPosY, Float:cPosZ,
        Float:x1, Float:y1, Float:z1,
        Float:x2, Float:y2, Float:z2,
        Float:dX, Float:dY, Float:dZ;
    GetVehiclePos(GetPlayerVehicleID(playerid), x1, y1, z1);
    GetPlayerCameraPos(playerid, cPosX, cPosY, cPosZ);
    GetPlayerCameraFrontVector(playerid, cX, cY, cZ);
    x2 = FireInfo[fireid][firePosX];
    y2 = FireInfo[fireid][firePosY];
    z2 = FireInfo[fireid][firePosZ];
    new Float:Dist = GetDistanceBetweenPoints(x1, y1, z1, x2, y2, z2);
    dX = cPosX + floatmul(cX, Dist);
    dY = cPosY + floatmul(cY, Dist);
    dZ = cPosZ + floatmul(cZ, Dist);
    if(GetDistanceBetweenPoints(x1, y1, z1, dX, dY, dZ) <= 50.0)
    {
        return true;
    }
    return false;
}
I never worked with cameras before (Except doing the class screen).
The problem in this code is: wherever I look, it does something, doesn't matter where am I looking at, though it supposed to do something when I'm looking at the exact point.
Reply


Messages In This Thread
Getting Player's Camera Look At - by Maxips2 - 04.10.2010, 16:15
Re: Getting Player's Camera Look At - by samgreen - 04.10.2010, 16:37
Re: Getting Player's Camera Look At - by zfkdaniel - 04.10.2010, 18:57
Re: Getting Player's Camera Look At - by Maxips2 - 04.10.2010, 19:35
Re: Getting Player's Camera Look At - by Mauzen - 05.10.2010, 12:21
Re: Getting Player's Camera Look At - by Maxips2 - 05.10.2010, 13:29
Re: Getting Player's Camera Look At - by Mauzen - 05.10.2010, 13:35
Re: Getting Player's Camera Look At - by Maxips2 - 05.10.2010, 14:08
Re: Getting Player's Camera Look At - by Mauzen - 05.10.2010, 14:15
Re: Getting Player's Camera Look At - by Maxips2 - 05.10.2010, 14:18

Forum Jump:


Users browsing this thread: 2 Guest(s)