UniStorm Weather System Wiki
Advertisement
Bandicam 2015-10-07 18-31-46-609

Introduction to the Dynamic Plant Growth System

The Dynamic Plant Growth System works by tracking UniStorm's Weather, Time, Sunlight, and Temperature. If the conditions are met, (Examples) the Sun Intensity has reached 0.5, the Rain Intensity has reached 100, the current Temperature is greater than 70 degrees, etc., then roll a grow. This will only happen once per UniStorm Hour. When the system rolls, it has a 0% to %100 chance to grow, depending on your customized odds. This is similar to how Minecraft does their plant system. We used this approach because it adds a dynamic touch to the plants allowing some of them to be bigger than others. Plants will grow on an X, Y, and Z axis according to the amount set within the Editor. Once the Max grow size is reached, the system is turned off. The Max Growth amount applies to each axis. We used a variable isFullyGrown and made it public to be used for things like harvesting.

From here on we will refer to Dynamic Plant Growth System as DPGS.



The Editor

This is the DPGS's editor has many help box explaining what each setting does. However, like all new systems, an editor can seem a bit overwhelming at first glance. So, we will talk in depth about each section of the Editor and its variables. This should help get you familiarize with editor.

GrowthSystem(WIP2)



Growing Conditions

A plant will grow based off of things we call conditions. DPGS has 3 conditions that can be met in order for a plant to roll for a grow. These rolls are based off of odds from Never (0%) to Always (100%). You can adjust the odds for each condition. A plant will only roll for a grow once every UniStorm Hour. We will discus odds after we have explained all conditions.

  • Precipitation - Growing from Precipitation will allow your plants to grow once the Rain Needed to Grow (UniStorm's current Rain Intensity) has been met. The system will then roll to see whether or not your plant will grow. You can control the odds below from a percent, to never, or to always. This process will only happen once per UniStorm Hour.
  • Temperature - Growing from Temperature will allow your plants to grow once the Temperature Needed to Grow (UniStorm's current Temperature) has been met. The system will then roll to see whether or not your plant will grow. You can control the odds below from a percent, to never, or to always. This process will only happen once per UniStorm Hour.
  • Sunlight Intensity - Growing from Sunlight Intensity will allow your plants to grow once the Sunlight Intensity Needed to Grow (UniStorm's current Sunlight Intensity) has been met. The system will then roll to see whether or not your plant will grow. You can control the odds below from a percent, to never, or to always. This process will only happen once per UniStorm Hour.



Growth Amounts and Odds

When the system rolls, it has a 10% to %100 (including Never or Always) chance to grow, depending on your customized odds (See Picture Below). This allows plants' size to vary because some of your plants may roll a grow, while others won't. This may make some plant harvestable sooner than others. Plants will grow on an X, Y, and Z axis according to the amount set within the Editor. Once the Max grow size is reached, the system is turned off. The Max Growth amount applies to each axis. When your plant is has finished growing for all 3 axes, the variable isFullyGrown will become true. This can be used for events by creating custom scripts. We will talk about custom events and scripts further along the documentation.

GrowthSystem(WIP3)



Inhibiting Conditions (Inhibitors)

Inhibiting Options controls what conditions stop your plant from growing, such as a certain season or below a certain temperature. Inhibiting Options will affect all Growth Options for each Inhibitor that is active stopping the plant from growing until that condition is passed. For example: If the season is Winter, and the Inhibitor for Winter is enabled, the plant will no longer grow even though the Sunlight Intensity has been reached. Once Winter is over, the plant will continue to grow as it should when the Sunlight growth condition has bee met. The Inhibitors are as followed:

  • Season Inhibitor - The Season Inhibitor will stop this plant from growing when UniStorm reaches the assigned Season. Your choices are Spring, Summer, Fall, and Winter.
  • Temperature Inhibitor - The Temperature Inhibitor will stop this plant from growing if the temperature falls below the Min Temperature.
Inhibitors



Custom Events and Scripts

Customer events and scripts can be used for things like checking to see if a plant is fully grown making it harvestable.

If you would like to check to see if a plant is harvestable, see the below script. This script uses a raycast to check the plant that is in the middle of the screen if the plant has a tag named "Plant" and if it's within view. You will need to apply a collider to your plant in order for this to work. A sound effect can be used if desired which plays by either checking or harvesting.

//By: Black Horizon Studios
//To be used with UniStorm

using UnityEngine;
using System.Collections;

[RequireComponent (typeof (AudioSource))]

public class HarvestCheck : MonoBehaviour {

	public string harvestTagName = "Plant";
	public float harvestDistance = 6.0f;
	public AudioClip harvestSound;
	private Ray ray;
	private RaycastHit hit;
	private AudioSource audio;

	void Start () 
	{
		audio = GetComponent<AudioSource>();

		if (harvestSound == null)
		{
			Debug.LogWarning("You have not added a sound to Harvest Sound of this script. Sounds will not be used.");
		}
	}

	void FixedUpdate () 
	{
		if(Input.GetMouseButtonDown(0))
		{
			ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f));
			
			if (Physics.Raycast(ray, out hit, harvestDistance))
			{
				CheckHarvest();
			}
		}
	}
	
	void CheckHarvest ()
	{
		if (hit.collider.tag == harvestTagName)
		{
			if (harvestSound != null)
			{
				audio.PlayOneShot(harvestSound);
			}

			if (hit.collider.gameObject.GetComponent<PlantGrowthSystem>().isFullyGrown)
			{
				Debug.Log("This plant is fully grown!");
			}

			if (!hit.collider.gameObject.GetComponent<PlantGrowthSystem>().isFullyGrown)
			{
				Debug.Log("This plant is not fully grown yet, come back later.");
			}
		}
	}
}



Advertisement