Jump to content
Sign in to follow this  
bigshotking

Object in Players Field of View

Recommended Posts

Hello everyone,

I was wondering if anyone could help me out, it has been a while since I've scripted for Arma and I I'm completely lost on this. I need help writing a script/function that when an object is in the players view it calls a function or script. So if the object is out of the players view then it does nothing, but when it comes into their field of view it will call a function or script.

Thanks,

-Bigshot

Share this post


Link to post
Share on other sites

Okay I'm not exactly sure what you are trying to achieve exactly?

To determine if the object is within the players monitor FOV would most likely need:

worldToScreen to convert the objects world position to it's screen position.

SafeZone will allow you to determine if the objects screen position is within the viewable zone.

terrainIntersect and lineIntersects can be used to check if the object is obscured by terrain or an object.

Distance can be used if the script requires the object to be a certain distance from the player before the script commences.

This should give you a start at least.

Blake.

Edited by blakeace

Share this post


Link to post
Share on other sites

What I'm trying to achieve is if the object is in the players Field of View (FOV). Then the script/function calls another script or function. I'll read up on those links you posted and have a try at it.

Thanks,

-Bigshot

Share this post


Link to post
Share on other sites

It'll be a lot easier to just use cursorTarget for the player to be looking directly at it but the new interest commands might work too.

Share this post


Link to post
Share on other sites

Well I'm not looking for him looking exactly at the object, if it is within his screen or FOV then then the function would return true

Share this post


Link to post
Share on other sites

Maybe Mando Angles is something you're looking for. It is for Arma, but should still work. I would think you could adapt to your needs...

Here is the description:

mando_angles.sqf v1.0 by Mandoble

  Returns the angle between obj1 and obj2, the degrees that obj1 needs to turn to have obj2 centered horizontally and
  check whether obj2 is inside field of view of obj1
  Negative means turning left, positive means turning right
  The returned value is in the form [angle, angle to turn, inside FOV true/false]

It can be found here:

Mando Angles

Share this post


Link to post
Share on other sites

Hi,

blakeace actually gave you all you need to make a very robust script.

Okay I'm not exactly sure what you are trying to achieve exactly?

To determine if the object is within the players monitor FOV would most likely need:

worldToScreen to convert the objects world position to it's screen position.

SafeZone will allow you to determine if the objects screen position is within the viewable zone.

terrainIntersect and lineIntersects can be used to check if the object is obscured by terrain or an object.

Distance can be used if the script requires the object to be a certain distance from the player before the script commences.

This should give you a start at least.

Blake.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×