Unity Procedural Flood Fill by johnasharifi - 3

ToolsProcedural

tool for filling a surface procedurally

Unknown VersionUnknown LicenseUpdated 1 year agoCreated on August 1st, 2018
Go to source

Unity Procedural Flood Fill

Introduction

Seeds a 2D array at random, then uses a breadth-first-search algorithm to populate the rest of the 2D array with data.

Image 1

Image 2

Implementation details

This implementation transforms a 2D array into a hex grid, but your implementation can be any kind of Node structure as long as it supports a function to get adjacent nodes (GetAdj()). This implementation relies upon the properties of the 2D array to detect node adjacencies. If nodes have their adjacencies specified beforehand, no backing 2D array is needed.

Nodes which have their property “value” populated will propagate their values to adjacent nodes. A breadth-first pass through the graph is used to give all nodes a non-zero value.

How to use

Create a gameObject and attach ScriptFillerNode to it. Create a gameObject prefab which has a ScriptNode attached to it or in some way supports a GetAdj() call. The ScriptFillerNode will instantiate all nodes, will set a few seed node values, and will then propagate those values through the grid of nodes.

Show all projects by johnasharifi