The Daily Click ::. Forums ::. Klik Coding Help ::. Advanced line of sight (not another regular)
 

Post Reply  Post Oekaki 
 

Posted By Message

hapsi



Registered
  13/11/2003
Points
  775
17th January, 2013 at 17/01/2013 09:23:38 -

In my line of sight (los from now on) when npc's are in certain distance of player/opponent they start shooting these los objects in their vision directions (<180°). As the object has been traveling off from over the npc, value a is turned to 1. When it hits an opponent, value a is turned to 2, scale to ~5, it turns 180°, and doesn't disappear when collides to an obstacles. When it hits back to the "sender" the sender rotates in the direction of the sight object +180° and awareness rises. And when the sight object returns to npc like this the second time, a shooting mode is turned on. Sight objects are not created more if there are over 75 of them (compromise between performance and functionality).

Image

This all works fine when there are less friendly characters ~5, but i wish i could do this with scaling an object or maybe even better: just calculation. How is that possible with multiple enemies and friends and the player + angle and floop scaling, while in combat of ~10vs10? all the npc's should pick the closest one, the one that they can see, and constantly checking if they can see any of the other npc's or closer npc. I tried this with couple of ways from the tutorials/ articles section, but they are all designed to enemies vs player alone, and no friendly vs enemies fights.

And yes i tried the formula described above, but the fps drop was dramatic. Is there any decent tutorial for large npc fights (max 20 vs 20 and the player with another team) with better performance?

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!
17th January, 2013 at 17/01/2013 15:23:01 -

I'll make you an example. You'll have to bear with me a while though...

 
n/a

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!
17th January, 2013 at 17/01/2013 17:27:31 -

Here: http://www.sketchy.co.nf
It's the fourth one down ("Team-based Line-of-Sight").

I'm getting just over 200 FPS in the example (with a little trickery), but you won't be able to achieve anything like that in an actual game - the objects will be further apart (making the obstacle detection part slower) and there'll be a lot of other stuff going on at the same time - but if you can manage 50-60 FPS that's still going to be good enough.

It occurred to me that you probably don't even need (or want) each unit to have their own independent sight calculations though, as units could communicate with one another - so if an enemy is visible to one unit, it should be visible to all (though it obviously should not be targeted if there is no clear line-of-fire).

 
n/a

hapsi



Registered
  13/11/2003
Points
  775
17th January, 2013 at 17/01/2013 21:32:26 -

@Sketchy Yes the npc's communicate so that if one near of another is close to a one that sees opponent, it tells to a friend about it. I'll check your link tomorrow and see if it helps me. Thank you anyways.

 
[Signature][/Signature]

hapsi



Registered
  13/11/2003
Points
  775
18th January, 2013 at 18/01/2013 18:26:37 -


Originally Posted by Sketchy
Here: http://www.sketchy.co.nf
It's the fourth one down ("Team-based Line-of-Sight").

I'm getting just over 200 FPS in the example (with a little trickery), but you won't be able to achieve anything like that in an actual game - the objects will be further apart (making the obstacle detection part slower) and there'll be a lot of other stuff going on at the same time - but if you can manage 50-60 FPS that's still going to be good enough.

It occurred to me that you probably don't even need (or want) each unit to have their own independent sight calculations though, as units could communicate with one another - so if an enemy is visible to one unit, it should be visible to all (though it obviously should not be targeted if there is no clear line-of-fire).



If i understood the example right, it only tells when ever the pink or blue character sees the opponent. What i need is witch one of the opposite character it sees AND it to be able to turn to it's direction(via direction calculator object). I'm not familiar with the extension though. Can it be created so that it shoots some kind of LoS object to only the direction of enemy(the one it sees and is nearest)? Or is it even necessary?

 
[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!
18th January, 2013 at 18/01/2013 19:10:50 -

Each object has an alterable value called "FixedOfNearest". This holds the fixed value of the nearest enemy which the object can see (if you move the mouse over an object, that enemy will be circled), or if it can't see an enemy the value will be "0".

It's pretty trivial to make each object turn to face the enemy whose fixed value matches its "FixedOfNearest".
You could just add the line:

#28
+ On ForEach loop "LoSPink" for Pink
+ Fixed value of Blue = FixedOfNearest("Pink")
-> Pink: turn towards Blue...

...and also the equivalent event for the Blue team.

And no, you don't need to shoot any LoS objects - checking for obstacles is already taken care of with an embedded detector, as are distance and relative angle comparisons (so an enemy won't be visible if it's standing behind the object, or if it's too far away). The maximum vision range and field-of-view (angle) are held in alterable values, so they can be easily changed.

This is a slightly modified version, where enemies that have been spotted by one object, become visible to all: http://sdrv.ms/YdEQQo
It's a bit more realistic, and seems to be a little more efficient (gives an improvement of about 15-30 FPS).
If you want objects to only communicate with other nearby friendlies, that would be considerably more complicated (unlikely to be worth the effort and reduced performance).

Edited by Sketchy

 
n/a

hapsi



Registered
  13/11/2003
Points
  775
19th January, 2013 at 19/01/2013 08:21:00 -

@Sketchy i couldn't find select.mfx extension.. Can you point it out for me?

 
[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!
19th January, 2013 at 19/01/2013 12:50:28 -

Select.mfx is the "Select Object" extension:
http://vps.dynamicarcade.co.uk/downloads/extensions2/Select/Select%20Object%20v0.11%20beta.zip

 
n/a
   

Post Reply



 



Advertisement

Worth A Click