Advertisement
Guest User

Untitled

a guest
May 24th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class TreeToLog : MonoBehaviour {
  6.  
  7. public int TreeLife = 0;
  8. public GameObject tree;
  9. public GameObject log;
  10. public GameObject treeBottom;
  11. public Vector3 oldPosition;
  12. public Vector3 newPosition;
  13. public Quaternion newRotation;
  14. public Quaternion oldRotation;
  15. public Rigidbody rb;
  16.  
  17. void Start()
  18. {
  19. rb = GetComponent<Rigidbody> ();
  20. }
  21.  
  22. // Use this for initialization
  23. void Update ()
  24. {
  25. TreeToLogs ();
  26. }
  27.  
  28.  
  29. // Coroutine qui
  30. IEnumerator Coroutine()
  31. {
  32. yield return new WaitForSeconds (Random.Range(5f, 100f));
  33. Debug.Log ("Test");
  34. newPosition = oldPosition;
  35. newRotation = oldRotation;
  36. Instantiate (treeBottom, newPosition, newRotation);
  37. rb.isKinematic = false;
  38. Destroy (tree);
  39. Instantiate (log, oldPosition, oldRotation);
  40. }
  41.  
  42. IEnumerator Coroutine2()
  43. {
  44. yield return new WaitForSeconds (3f);
  45.  
  46. }
  47.  
  48. void PlaceTreeBottom()
  49. {
  50. }
  51.  
  52. void TreeToLogs()
  53. {
  54. if (TreeLife <= 100)
  55. {
  56. TreeLife++;
  57. }
  58. if (TreeLife >= 100)
  59. {
  60. oldPosition = transform.position;
  61. oldRotation = transform.rotation;
  62. StartCoroutine(Coroutine ());
  63. }
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement