Unity Harvesting

Introduction

HarvestableCollider is a C# script that defines the collider for the harvestable objects in the game. The script is part of a larger game development project and is responsible for determining the size, shape, and position of the collider for harvestable objects.

The main purpose of the HarvestableCollider is to ensure that when a player character comes into contact with a harvestable object, the player can interact with it, causing it to be harvested. The collider is used to detect when the player is close enough to the object to harvest it, and it also determines the area of the object that can be harvested.

The HarvestableCollider script is attached to each harvestable object in the game, and it is responsible for setting the collider’s size, shape, and position. The script uses various parameters to determine these properties, including the object’s scale, position, and rotation.

The script also includes a method for detecting when a player is close enough to harvest the object. When the player character comes into contact with the collider, the script checks to see if the player has the necessary tools to harvest the object. If the player has the tools, the object is harvested and removed from the game world.

The HarvestableCollider script is an important part of the game development process because it enables the player to interact with the environment in a meaningful way. Without the collider, the player would not be able to harvest objects, which would significantly reduce the game’s playability.

Overall, the HarvestableCollider is an essential component of the game’s mechanics, and it plays a crucial role in enabling the player to interact with the game world. Its proper implementation ensures that players can enjoy the game’s mechanics and complete objectives, leading to an enjoyable gaming experience.

Overview

The HarvestableCollider class is a C# script that is used to define a harvestable object in a game developed with the HNGamers framework. This script defines various properties of the object, such as its index in the terrain tree list, color, height, lightmap color, position, prototype index, rotation, width scale, and harvesting restore time. The script also defines methods to destroy the object and handle mouse events when the mouse pointer is over the object.

Interface pages:

None.

Constructor pages:

None.

Method pages:

Method Name Return Type Description
DestroySelf() void Destroys the game object.

Property pages:

Property Name Type Description
terrainIndex int The index of the object in the terrain tree list.
color Color32 The color assigned to the object.
height float The height of the object.
lightmapColor Color32 The lightmap color assigned to the object.
position Vector3 The position of the object.
prototypeIndex int The prototype index of the object in the terrain tree list.
rotation float The rotation of the object.
widthScale float The width scale of the object.
harvestingRestoreTime float The time it takes for the object to restore after being harvested.
terrainInstance Terrain The instance of the terrain on which the object is located.
terrainInstanceName string The name of the instance of the terrain on which the object is located.

Event pages:

Event Name Return Type Description
OnMouseExit() void Unity event that is called when the mouse pointer exits the object’s collider.
OnDestroy() void Unity event that is called when the object is destroyed.
OnMouseOver() void Unity event that is called when the mouse pointer is over the object’s collider.

Concept/guide pages:

None.

Examples:

None.