Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class TreeToLog : MonoBehaviour {
- public int TreeLife = 0;
- public GameObject tree;
- public GameObject log;
- public GameObject treeBottom;
- public Vector3 oldPosition;
- public Vector3 newPosition;
- public Quaternion newRotation;
- public Quaternion oldRotation;
- public Rigidbody rb;
- void Start()
- {
- rb = GetComponent<Rigidbody> ();
- }
- // Use this for initialization
- void Update ()
- {
- TreeToLogs ();
- }
- // Coroutine qui
- IEnumerator Coroutine()
- {
- yield return new WaitForSeconds (Random.Range(5f, 100f));
- Debug.Log ("Test");
- newPosition = oldPosition;
- newRotation = oldRotation;
- Instantiate (treeBottom, newPosition, newRotation);
- rb.isKinematic = false;
- Destroy (tree);
- Instantiate (log, oldPosition, oldRotation);
- }
- IEnumerator Coroutine2()
- {
- yield return new WaitForSeconds (3f);
- }
- void PlaceTreeBottom()
- {
- }
- void TreeToLogs()
- {
- if (TreeLife <= 100)
- {
- TreeLife++;
- }
- if (TreeLife >= 100)
- {
- oldPosition = transform.position;
- oldRotation = transform.rotation;
- StartCoroutine(Coroutine ());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement