Guest User

trash code that should never be refrenced

a guest
Sep 30th, 2020
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using Unity.Mathematics;
  4. using UnityEngine;
  5.  
  6. public class GroundMovement : MonoBehaviour
  7. {
  8. public float globalspeed;
  9. Vector2 startpos;
  10. public Transform GroundParent;
  11.  
  12. public GameObject Ground1;
  13. public float Ground1Speed;
  14. public float upPos1;
  15.  
  16. public GameObject Ground2;
  17. public float Ground2Speed;
  18. public float upPos2;
  19.  
  20. public GameObject Ground3;
  21. public float Ground3Speed;
  22. public float upPos3;
  23.  
  24. private int reset = 1;
  25.  
  26.  
  27. // Start is called before the first frame update
  28. void Start()
  29. {
  30. startpos = Ground1.transform.position;
  31. }
  32.  
  33. // Update is called once per frame
  34. void Update()
  35. {
  36. //suuuuper bad implemantation
  37. float newPos = Mathf.Repeat(Time.time * globalspeed, 20);
  38. Ground1.transform.position = startpos + new Vector2(reset, upPos1) * newPos * Ground1Speed;
  39. Ground2.transform.position = startpos + new Vector2(reset, upPos2) * newPos * Ground2Speed;
  40. Ground3.transform.position = startpos + new Vector2(reset, upPos3) * newPos * Ground3Speed;
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment