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
Edgeclass prepended to theGraphclass in the same fileDefining the
GetEdgesfunction in theGraphclassHaving the
Vertexclass
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
VertexVisibilityclass deriving fromVertex:using UnityEngine; using System.Collections.Generic; public class VertexVisibility : Vertex { void Awake...