SceneBoundary - jimdroberts/FishMMO GitHub Wiki
SceneBoundary is a MonoBehaviour for FishMMO that defines a scene boundary in the game world. It draws gizmos for visualization in the Unity editor and provides methods to get the boundary's size and offset, enabling clear and interactive boundary management for gameplay logic.
-
[Tooltip] public Vector3 BoundarySize
The size of the scene boundary. Boundaries are inclusive; if a player is not within it, it will not apply.
-
public void OnDrawGizmos()
Draws a wireframe cube gizmo in the editor to visualize the boundary.
-
public void OnDrawGizmosSelected()
Draws a solid cube gizmo in the editor when the boundary is selected.
-
public override Vector3 GetBoundaryOffset()
Gets the offset of the boundary, which is the object's position. Returns: Vector3. The position of the boundary object. No exceptions are thrown.
-
public override Vector3 GetBoundarySize()
Gets the size of the boundary. Returns: Vector3. The size vector of the boundary. No exceptions are thrown.
- Attach the SceneBoundary component to a GameObject in your scene to define a boundary area.
- Set the BoundarySize field to specify the size of the boundary.
- Use the provided methods to retrieve boundary size and offset in your gameplay logic.
// Example 1: Adding a scene boundary in the Unity Editor
// 1. Add the SceneBoundary component to a GameObject.
// 2. Set the BoundarySize in the inspector.
// 3. The boundary will be visualized with gizmos in the scene view.
// Example 2: Accessing boundary data in code
Vector3 offset = sceneBoundary.GetBoundaryOffset();
Vector3 size = sceneBoundary.GetBoundarySize();
- Use this component to clearly define and visualize scene boundaries for gameplay logic.
- Adjust BoundarySize to match the intended area for boundary checks.
- Document the purpose and configuration of each boundary for maintainability.