This commit is contained in:
miti99 committed 2018-09-24 23:31:59 +07:00
1 parent 8a77f67d6d
commit c0872dfe9d
58 files changed
+4740

No files matched your search

+26
View File
@@ -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;
}
}
}