Unit Vision

Published October 02, 2018
Advertisement

Subscribe to our subreddit to get all the updates from the team!

First off, here's a video that shows the unit vision in action : 

 

So, what is the unit vision? It's a simple mechanism that notifies a unit when another unit enters its vision field. It also takes into account if the vision is blocked by entities.

This is how it is implemented step by step :

  1. A cone ghost control is attached to the unit's head
  2. All units intersecting with the cone's AABB fire events (AABB because of how Bullet Physics work)
  3. Cast a ray towards the visible unit and then adjust the angle so that it fits in the cone
  4. If the ray cast touches the supposedly visible unit, then it is truly visible

 

Using the debug view of Bullet Physics in the jMonkey Engine 3.1, we're able to see what the vision cone actually looks like.

UnitVisionFromBehind.png.a0384bcbc7c06a11a280a8e0cf92f96c.png

UnitVisionConeFromTheSide.png.ed84913f5d96e4963c4126fccd6719a5.png

UnitVisionConeFromTheSide-2.png.458f46e114950884091d1b4065175194.png

 

And when inside the cone we can't see it because of culling. However, we can see the enemy's arm moving, which is a test I did for when a unit see another unit.

5acce1264179e_DesktopScreenshot2018_04.10-11_49_14.46(2).png.2d71b73e57da99d7494f4a99060c5268.png

 

Behind a box, the enemy does not move its arm because he can't see me.

5acce17928f5e_DesktopScreenshot2018_04.10-11_49_46.79(2).png.12a4edd9236536c0bdc28893e081d44a.png

5acce199c469f_DesktopScreenshot2018_04.10-11_49_50.47(2).png.7b7bcfbdebad80d002392903ff26a8db.png

 

But when I leave my hiding spot, he can see me again.

5acce1c9ade40_DesktopScreenshot2018_04_10-11_50_10.57(2).png.f991cdd3375c2729e6c6b807d225cd88.png

0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement