Jump to content

3d plant growing?


erik3227

Recommended Posts

using System.Collections;
using System.Collections.Generic;
using UnityEditor.Profiling.Memory.Experimental;
using UnityEngine;

public class GrowingPlant : MonoBehaviour
{
    public float growspeed = 0.01f;
  
    private void Start()
    {
        transform.parent.GetComponent<BoxCollider>().enabled = false;
    }

    void Update()
    {
        if (transform.localScale.x < 1.0)
        {
            transform.localScale += new Vector3(0.1f,0.1f,0.1f) * Time.deltaTime * growspeed;
        }

        if (transform.localScale.x >= 0.9f)
        {
            transform.parent.GetComponent<BoxCollider>().enabled = true; //Ready for harvesting
        }
    }
}

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...