Jump to content

How to tell if a ped facing another ped?


Cassandra

Recommended Posts

Posted
I guess that you could use rotation to check if he's facing another ped.

You can but the rotation has to be accurate in that case it's very unlikely the ped will see the other ped script-wise.

Posted

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.

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

Posted

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.

  • MTA Team
Posted

um you could check the rotation, then check all element in a certain angle range from his position as an origin depending on a distance.

Posted
um you could check the rotation, then check all element in a certain angle range from his position as an origin depending on a distance.

Yeah, I thought about that. But, there's no function to complete the logic behind it.

  • MTA Team
Posted

write a function

Assuming you want to check until 200units start off with this: Get all the peds in a 200 unit radius

Posted
write a function

Assuming you want to check until 200units start off with this: Get all the peds in a 200 unit radius

I did checked the distance. I only need to check the rotation if the ped facing the other ped.

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