mirror of
https://github.com/tiennm99/flappy-bird.git
synced 2026-10-12 16:15:22 +00:00
27 lines
637 B
C#
27 lines
637 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Move : MonoBehaviour
|
|
{
|
|
public float moveSpeed;
|
|
public float moveRange;
|
|
private GameObject obj;
|
|
private Vector3 oldPosition;
|
|
void Start()
|
|
{
|
|
obj = gameObject;
|
|
oldPosition = obj.transform.position;
|
|
moveSpeed = 5.0f;
|
|
moveRange = 20f;
|
|
}
|
|
void Update()
|
|
{
|
|
obj.transform.Translate(new Vector3(-Time.deltaTime * moveSpeed, 0, 0));
|
|
if (oldPosition.x - obj.transform.position.x > moveRange)
|
|
{
|
|
obj.transform.position = oldPosition;
|
|
}
|
|
}
|
|
}
|