mirror of
https://github.com/tiennm99/flappy-bird.git
synced 2026-10-18 00:15:02 +00:00
Complete
This commit is contained in:
1 parent
8a77f67d6d
commit
c0872dfe9d
58 files changed
+4740
No files matched your search
@@ -0,0 +1,26 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user