Advertisement
kadyr

Untitled

Oct 24th, 2021
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class EnvMovment :MonoBehaviour
  4. {
  5. [SerializeField]
  6. private float scrollspeed;
  7.  
  8. [SerializeField]
  9. private int packcount = 10;
  10.  
  11. [SerializeField]
  12. private GameObject[] envpacks;
  13.  
  14. private void Start()
  15. {
  16. float counter = 0;
  17. for (int i = 0; i < packcount; i++)
  18. {
  19. var envprefab = Instantiate(envpacks[UnityEngine.Random.Range(0, envpacks.Length)],
  20. new Vector3(counter, 0, 0), Quaternion.identity);
  21. envprefab.transform.parent = this.transform;
  22. counter += 70f;
  23. }
  24.  
  25. }
  26.  
  27. // update is called once per frame
  28. void Update()
  29. {
  30. transform.position -= new Vector3(0, 0, scrollspeed * Time.deltaTime / 10);
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement