Large Water Area Manager

Creating Large Water Area Manager

We create a large water area manager object from the Hierarchy's Create menu:

2D Object → Game2D Water Kit → Large Water Area Manager Object

Create 2D Large Water Area Object from the Hierarchy's Create menu

A new large water area manager object is added in the Hierarchy, with a child water object.

Large Water Area Manager Object In Hierarchy With A Child Water Object

Large Water Area Manager Component Properties

Large Water Area Manager Component Properties

Main Camera

The Main Camera property sets the scene main camera that will be used to determine the visibility of each spawned water object. So when a water object is no longer visible to this camera, it gets properly repositioned.

Water Object

The Water Object property sets the base object from which to instantiate the other water objects. It is assigned by default to the child water object.

Important

The water object should have a width that is at least half of the Main Camera view frustum width.

Note

The water object doesn't necessarily have to be a child of the large water area manager object.

Water Object Count

The Water Object Count property sets the number of water objects to spawn when the game starts.

Script Reference

1
2
3
largeWaterAreaManager.MainCamera = mainCamera;
largeWaterAreaManager.WaterObject = waterObject;
largeWaterAreaManager.WaterObjectCount = 3;

Tip

We can get the water object that is located at a specific position using the function GetWaterObjectLocatedAt(float xWorldSpacePosition). This function returns null if there's currently no water object in that position

1
Game2DWater waterObject = largeWaterAreaManager.GetWaterObjectLocatedAt(5f);