BGMove.cs 614 B

1234567891011121314151617181920212223
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class BGMove : MonoBehaviour {
  5. // Use this for initialization
  6. void Start () {
  7. }
  8. // Update is called once per frame
  9. void Update () {
  10. //背景移动
  11. // transform.Translate(Vector3.forward*1f*Time.deltaTime);
  12. // if (this.transform.position.z>=21.6f)
  13. // {
  14. // this.transform.position = new Vector3(0,0,0f);
  15. // }
  16. //mathf方法背景移动
  17. transform.position = new Vector3(transform.position.x,transform.position.y,Mathf.Repeat(Time.time,21.6f));
  18. }
  19. }