FIFE forums

Please login or register.

Login with username, password and session length
Advanced search  

News:

FIFE 0.4.0 has been released on 15th of January, 2017!

Author Topic: Line of sight/ clear shooting trajectory  (Read 542 times)

conan

  • Newbie
  • Posts: 17
    • View Profile
Line of sight/ clear shooting trajectory
« on: November 02, 2015, 08:15:21 pm »

Hi all,

I have spent few hours developing a nice little game with FIFE. I must say I really like it.

I hit a wall though, and that is getting a way to calculate if my units have clear line of fire to other units. I use a square grid.

So far what I tried is calculating two different routes from unit to target: one in the "units" layer and another one in a so called "trajectory" layer which has no blocking objects (it would take the shortest path possible). So if the paths match, then I have a clear line of sight. This works in most of the cases, but there are some exceptions when it doesn't work.

How would you do it?

Thanks!
Logged

conan

  • Newbie
  • Posts: 17
    • View Profile
Re: Line of sight/ clear shooting trajectory
« Reply #1 on: November 02, 2015, 08:53:52 pm »

Wow, I think I found it.  ;D

I'm now using:
 layer.getInstancesInLine(origin, destination)

I haven't totally implemented and tested it but it looks promising. Still open for feedback.

Cheers!
Logged