dinorun/Assets/Scripts/Obstacle.cs
2025-07-29 15:15:49 +05:30

24 lines
492 B
C#

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