Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using Unity.Mathematics;
- using UnityEngine;
- public class GroundMovement : MonoBehaviour
- {
- public float globalspeed;
- Vector2 startpos;
- public Transform GroundParent;
- public GameObject Ground1;
- public float Ground1Speed;
- public float upPos1;
- public GameObject Ground2;
- public float Ground2Speed;
- public float upPos2;
- public GameObject Ground3;
- public float Ground3Speed;
- public float upPos3;
- private int reset = 1;
- // Start is called before the first frame update
- void Start()
- {
- startpos = Ground1.transform.position;
- }
- // Update is called once per frame
- void Update()
- {
- //suuuuper bad implemantation
- float newPos = Mathf.Repeat(Time.time * globalspeed, 20);
- Ground1.transform.position = startpos + new Vector2(reset, upPos1) * newPos * Ground1Speed;
- Ground2.transform.position = startpos + new Vector2(reset, upPos2) * newPos * Ground2Speed;
- Ground3.transform.position = startpos + new Vector2(reset, upPos3) * newPos * Ground3Speed;
- }
Advertisement
Add Comment
Please, Sign In to add comment