The Daily Click ::. Forums ::. Klik Coding Help ::. Direction and position calculation
 

Post Reply  Post Oekaki 
 

Posted By Message

hapsi



Registered
  13/11/2003
Points
  775
17th October, 2015 at 17/10/2015 22:50:30 -

This is propably just basic math that i have forgotten, but how do you calculate the directional area (or seeing area) of an object? Let's say enemy sight in degrees of it's front.

Image

Edited by hapsi

 
[Signature][/Signature]

Airflow

imafirinmahlazr

Registered
  24/09/2003
Points
  -197

VIP MemberSonic SpeedSnow Cloud!Computer
19th October, 2015 at 19/10/2015 05:24:01 -

calculate the angle between the two objects and subtract that angle from the angle of the player
yep, simple

 
n/a

Fifth

Quadruped

Registered
  07/05/2003
Points
  5815

VIP MemberGOTW JULY 2010 WINNER!Kliktober Special Award TagGOTW HALLOWEEN 2011 WINNERPicture Me This Round 51 Winner!
20th October, 2015 at 20/10/2015 14:59:16 -

I could never figure out the math for that. There was always one extra detail that would give me a headache.

Just use the Advanced Direction Object. It has a function for determining the direction between two points, and one for determining the difference between to directions. So you find the direction between the seer and its target, and determine the difference between that and the seer's angle. If it's less than its range of vision, then it's seen.

Also, I believe CF2.5 has an "angle of a vector" function built in which you can use, but it's nice to use the Advanced Direction Object's "difference between two angles" anyway, because you don't have to worry about weird cases like crossing from 360 degrees to 0 degrees, or dealing with negative angles, or angles higher than 360 degrees. It just simplifies things.

 
Go Moon!
   

Post Reply



 



Advertisement

Worth A Click