Jump to content

How to tell if a ped facing another ped?


Cassandra

Recommended Posts

To check if the ped is facing another you need to find the rotation, to check if the ped can see the other you have to check if the client player is some element so that the function doesn't get called for all because the function uses the local player.

So, you would do this:

if ( thePlayerElement == localPlayer ) then 
    if ( isElementInPhotograph ( otherElement ) ) then 
        --do something 
    end 
end 

Be sure to copy the function to your file, it's not a built-in one.

Link to comment
To check if the ped is facing another you need to find the rotation, to check if the ped can see the other you have to check if the client player is some element so that the function doesn't get called for all because the function uses the local player.

So, you would do this:

if ( thePlayerElement == localPlayer ) then 
    if ( isElementInPhotograph ( otherElement ) ) then 
        --do something 
    end 
end 

Be sure to copy the function to your file, it's not a built-in one.

I got the seeing part but not the rotation part. For example if the ped crouch sideways but still behind another ped, the ped sees it.

Edit: IsElementOnScreen doesn't work for peds only players.

Link to comment

Ah, well.. You're really talking about peds and not players.. Then I don't know how would you see if a ped can see some element, peds aren't user-controlable and so I don't think you can check if the ped is seeing another element. But you should not rely on my words, because I may be wrong.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...