Home   Help Search Login Register  

Author Topic: check for a clear 3d straight line path (need mathmatical forumla)  (Read 1010 times)

0 Members and 1 Guest are viewing this topic.

RedHouse

  • Guest
My problem is I am not so good at maths, does anyone have a script or funciton that checks that the straight line between two points does not pass through any ground such as hills. The reason I need this formula is becuase I am working on a script so when an AI soldier knows the roughly the location of an enemy soldier but cannot see him directly he will supress that position with indirect fire.

Would apreciate any Redhouse
« Last Edit: 22 Aug 2006, 05:20:10 by RedHouse »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
A quick thought, and it doesn't require much maths:

Create a Game Logic at the location of one point.  Have a loop that moves it slightly towards the other point (in all three dimensions) and keep looping until it gets there.  In each loop check the height of the GL above ground if it is <= 0 then there is some earth in the way.

Will not detect buildings or trees though.  Also you would need to remember that getPos XX select 2 will give you the height above ground level.  You would need to use the heights above sea level to determine the path to be followed by the GL.  To get the height above sealevel just setPos a tigger each of the locations.  Triggers are setposed at sea level so you can then use that to work out the absolute location of each point.

I think the failure to detect buildings and trees could be a killer here though
« Last Edit: 22 Aug 2006, 18:03:05 by THobson »

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Here is an old topic about LOS script(s)..

May prove to be usefull..
Didn't read the whole thread just now so dunno if it ever was completed, or was some major setback discovered...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

RedHouse

  • Guest
@Thobson,
Thats the first thing that popped into my head, but I thought I'd check if someone had already done it before I atempted it myself.

@h-
Thanks that's helpful