25 lines
549 B
C#
25 lines
549 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Obstacle : MonoBehaviour
|
|
{
|
|
private float leftEdge;
|
|
public float movingItemSpeed = 1f;
|
|
|
|
private void Start()
|
|
{
|
|
leftEdge = Camera.main.ScreenToWorldPoint(Vector3.zero).x - 2f;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
transform.position += Vector3.left * GameManager.Instance.gameSpeed * Time.deltaTime * movingItemSpeed;
|
|
if (transform.position.x < leftEdge)
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
|
|
}
|
|
}
|