• Mods are now organized as resources. Use the Mods link above to browse for or submit a mod, tool, or prefab.

    The TFP Official Modding Forum Policy establishes the rules and guidelines for mod creators and mod users.

3d plant growing?

erik3227

Refugee
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