using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class bgmove : MonoBehaviour
{
// Start is called before the first frame update
public Transform bg;
public Transform gb;
public float speed = 1;
float y = 1f ;
void Start()
{
bg = this.GetComponent<Transform>();
}
public void Change()
{
if (y < -1)
y = 1;
}
public void move()
{
y = y - 0.05f;
bg.Translate(new Vector3(0, y, 0) * speed * Time.deltaTime);
}
// Update is called once per frame
void Update()
{
StartCoroutine(load());
IEnumerator load()
{
yield return new WaitForSeconds(0.01f);
}
move();
Change();
//yy = GameObject.Find("bg").GetComponent<Transform>().position.y;
//if(yy<2)
//bg.Translate(new Vector3(0,1,0) * speed * Time.deltaTime);//物体自己移动
//if (yy > 2)
//{
// bg.Translate(new Vector3(0, -1, 0) * speed * Time.deltaTime);
//}
}
}
一个丝滑的弹跳功能
最新推荐文章于 2024-06-14 10:05:46 发布