Representing the world with points of visibility
This is another widely-used technique for world representation based on points located throughout the valid area of navigation, whether manually placed or automated via scripting. We'll be using manually-placed points connected automatically via scripting.
Getting ready
Just like the previous representation, it's important to have several things in order before continuing:
- Having the
Edge
class prepended to theGraph
class in the same file - Defining the
GetEdges
function in theGraph
class - Having the
Vertex
class
Note
The vertex objects in the scene must have a collider component attached to them, as well as the Vertex
tag assigned. It's recommended for them to be unitary Sphere
primitives.
How to do it...
We'll be creating the graph representation class as well as a custom Vertex
class:
- Create the
VertexVisibility
class deriving fromVertex
:using UnityEngine; using System.Collections.Generic; public class VertexVisibility : Vertex...