The Daily Click ::. Forums ::. Klik Coding Help ::. Most realistic or most effective line of sight
 

Post Reply  Post Oekaki 
 

Posted By Message

hapsi



Registered
  13/11/2003
Points
  775
25th August, 2012 at 25/08/2012 12:20:31 -

I'm referring to "line of sight" with "LOS" from now on.

There are three ways of doing LOS that i know of:

1. The shoot of LOS-objects to see.
2. The scaling of an LOS-active dot.
3. An active, the size of seeing field that stays in position and direction of seeing character.

Obviously 3. doesn't fit in a game with lots of obstacles. I'm using method 1. because it has realisticity and randomness with certain functions. In my game it needs MAX 150 active objects (normally 50) and that eats memory and cpu. It still works without fps drop with my computer (old piece of crap).

So, is there other effective and yet as realistic ways of doing line of sight as 1.? Share your formulas here...

Image

Edited by hapsi

 
[Signature][/Signature]

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
25th August, 2012 at 25/08/2012 16:45:48 -

The simplest method is to just shoot detectors in the approximate direction in which the object is facing (with either random or uniform spread). Unfortunately, this is extremely buggy. If the detectors are too small, they'll miss objects which they should hit (esp. at long range). If too big, they'll hit obstacles which they should miss (esp. at close range). If detectors are moved by fastloop, that can be very CPU-intensive. If not, the time lag can exacerbate the accuracy problems. You also can't tell where the LoS between specific objects is blocked, which is sometimes useful.

Using a cone-of-vision detector is not really a method of checking LoS. All it does is check distance and angle - which can be done more efficiently using pure maths. If you use one of the following methods, it's important to do that first, as you'll often be able to omit the computationally expensive step of checking the LoS.

The alternative methods are really just variations on a theme. You use nested ForEach loops to check each combination of seeker and target objects in turn, and then either:
A. Scale and rotate a detector object to draw a line between them. This is the most efficient method - esp. on runtimes which handle graphics well (eg. Windows with HWA).
B. Move a detector from the seeker to the target object. This is generally less efficient, although it's possible to sacrifice some accuracy/reliability for performance, by moving the detector in larger increments. The main advantage is that it allows you to easily find the exact point at which the LoS is blocked (not just if is blocked). However, it would probably still be more efficient (but complicated) to use the previous method, combined with a binary search.

Incidentally, MMF2 also has a condition to select all objects on a line between two points, which would be ideal for checking LoS - except that it doesn't work.

 
n/a

hapsi



Registered
  13/11/2003
Points
  775
25th August, 2012 at 25/08/2012 19:42:16 -

Here is my methods for randomnes and realism:
-The object gets larger when it hits the opponent and turns back to the sender
-The object x,y, constantly random(~3) (unless already collided with someone)
-NPC only gets more aware of the enemy when receiving the "LoS". When "aware" enough, it starts attack
-Some actives like cropfield, bushes, furniture, and sandbag covers sets a certain flag on in "Los" object on collision. So you are cover if you prone. In prone you have to be close enough to the cover. When In a cropfield or a bush, only some of the Los will be destroyed when close to you(depending on pronemovement, loudness, and previous actions).

Here is a pic of NPC Friend(left, and NPC Enemy fighting. I made the "LoS"'s visible. "Los"Friend=green
Image

Improvement ideas?

Edited by hapsi

 
[Signature][/Signature]

Chris Donovan



Registered
  15/06/2003
Points
  448
26th August, 2012 at 26/08/2012 22:22:38 -

I don't have a strong background in mathematics, so I had to use a purely visual method for my zombie game. I used a wide, rotating cone, plus small LOS objects. If the player character can't see the enemy due to an obstacle or facing, then the player can't see the enemy, so you should have a fairly good idea if it works or not. I think it works for my game because it isn't very fast. It would probably fail miserably if the game play was faster, or if there were more characters on the screen. As is, there are only a maximum of 13.

My zombies simply have a percentage chance to notice the player if their LOS object hits.

Here's the download page.

http://www.misterdonovan.com/deadmiles/

Is your game available at all?

 
Send me feedback on my latest game, It Never Ends.


http://www.misterdonovan.com/it-never-ends/info/

hapsi



Registered
  13/11/2003
Points
  775
27th August, 2012 at 27/08/2012 13:50:56 -

I was thinking about releasing one level sandbox beta, but i have some issues that i'll have to do first. In sand box you could create stuff and characters and there would be different types of battlefields in one map. Good way to get bug reports i guess.

I guess the cone thing works very well when there is 1 or few players/friendly npc's(in that case the number of enemies doesn't matter witch is good for a zombie game).

[checking your game]--->

 
[Signature][/Signature]

hapsi



Registered
  13/11/2003
Points
  775
27th August, 2012 at 27/08/2012 14:18:01 -

How do you go from the "character info" to the position where you can play: move, see the player? I pressed eat, got some picture and i shot a few zombies and died. What i'm supposed to do to?

 
[Signature][/Signature]

Chris Donovan



Registered
  15/06/2003
Points
  448
30th August, 2012 at 30/08/2012 10:20:24 -

Sorry for not answering for so long. The goal of the The Dead Miles is to travel and meet other survivors. To travel, you click the footsteps icon on the top right. The only time you see your character is when you're attacked.

I am going to add more in game hints. I'm very old school when it comes to games and although I wrote thorough instructions, I have to understand that people don't have the patience to read them anymore.

Thanks for trying it.

 
Send me feedback on my latest game, It Never Ends.


http://www.misterdonovan.com/it-never-ends/info/

hapsi



Registered
  13/11/2003
Points
  775
30th August, 2012 at 30/08/2012 14:24:34 -

I actually read the instructions. I thought you see your character while travelling. How else are you supposed to know your location and items.
So it is more like manager game than top down zombie killing game?

 
[Signature][/Signature]

Chris Donovan



Registered
  15/06/2003
Points
  448
30th August, 2012 at 30/08/2012 18:48:43 -

Can we continue this in the General section under The Dead Miles? We're getting off topic here! Thanks.

 
Send me feedback on my latest game, It Never Ends.


http://www.misterdonovan.com/it-never-ends/info/

Chris Donovan



Registered
  15/06/2003
Points
  448
30th August, 2012 at 30/08/2012 18:48:48 -

Can we continue this in the General section under The Dead Miles? We're getting off topic here! Thanks.

 
Send me feedback on my latest game, It Never Ends.


http://www.misterdonovan.com/it-never-ends/info/
   

Post Reply



 



Advertisement

Worth A Click