• If you have a mod, tool or prefab, please use the Resources section. Click Mods at the top of the forums.

3d plant growing?

erik3227

New member
How to make growing 3d plant? Any example?
73250368-1591958028.png



Spoiler



 
Last edited by a moderator:
Code:
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
        }
    }
}
 
Back
Top