Checking if player is facing an object -
JaKe Elite - 27.07.2012
Hi,
I want to know how to check if player is facing an object.
Re: Checking if player is facing an object -
Misiur - 27.07.2012
Quite complex situation. You have to get relative position of player and object, then using trigonometry and compare required angle with GetPlayerFacingAngle (warning, 2d only, so it'll work for objects above player).
Other solution will require
https://sampwiki.blast.hk/wiki/GetPlayerCameraFrontVector
Re: Checking if player is facing an object -
JaKe Elite - 27.07.2012
Thank you.
Now i have another question.
How to detect the object id of players facing in.
Re: Checking if player is facing an object -
Kar - 27.07.2012
Facing a object by 'player angle' or 'camera' ?
Re: Checking if player is facing an object -
JaKe Elite - 27.07.2012
Player angle.
Re: Checking if player is facing an object -
AIped - 27.07.2012
maybe you can just use
pawn Код:
stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x, y, a);
GetPlayerFacingAngle(playerid, a);
if (GetPlayerVehicleID(playerid))
{
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
}
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}
mix it with isplayerinrangeofpoint and make sure that the x and y coordinates are the coordinates of the object, then it should check if the object is in front of you i think
Re: Checking if player is facing an object -
JaKe Elite - 27.07.2012
No, i was making Remove Building system.
here is my plan, i want to make auto detect object checking
if there is no object surronded then it will not check.
Re: Checking if player is facing an object -
Mauzen - 27.07.2012
Loop through all objects and check for each one if the player is facing it would be the most simple way.
Re: Checking if player is facing an object -
JaKe Elite - 27.07.2012
Sorry for being n00b is this correct?
I'm using Incognito's Streamer for some custom maps.
pawn Код:
for(new i = 0; i < CountDynamicObjects(); i++)
However i want to remove also the GTA SA Objects.
Re: Checking if player is facing an object -
JaKe Elite - 27.07.2012
BUMP