Jump to content

Detecting when entity is off screen doesn't work?


Recommended Posts

I need to figure out when a ped is not visible to the human player on their screen. I'm not talking about whether the player's ped has a line of sight to the ped, I'm talking about are there any pixels being displayed at this moment which belong to the ped. 

I would've thought the Entity.IsVisible or Entity.IsOnScreen properties would've done the trick, but both always seem to return true. 

Is there any way to do this? 

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

Link to comment
Share on other sites

Did you try the native IS_ENTITY_ON_SCREEN? From the nativeDB: "Returns true if the entity is in between the minimum and maximum values for the 2d screen coords. 
Still returns true even if the entity can't be seen yet is between the appropriate 2d screen coords (like above)." So it looks like it only detects if it is out of screen horizontally.

If that doesn't work you could use World.ConvertWorldPositionToScreenPosition() and check if it is inside the resolution rectangle, I haven't tried it but I think it should work.

Link to comment
Share on other sites

14 hours ago, alexguirre said:

If that doesn't work you could use World.ConvertWorldPositionToScreenPosition() and check if it is inside the resolution rectangle, I haven't tried it but I think it should work.

This seems to be working. Thanks. 

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...