using UnityEngine;

public class MoveOnlyThisObject : MonoBehaviour
{
    public float speed = 5f;

    // 🔒 BATAS Z SESUAI YANG KAMU KASIH
    public float minZ = -79.621f;
    public float maxZ = -78.878f;

    void Update()
    {
        float move = 0f;

        if (Input.GetKey(KeyCode.LeftArrow))
        {
            move = 1f; // dibalik jadi kanan
        }
        else if (Input.GetKey(KeyCode.RightArrow))
        {
            move = -1f; // dibalik jadi kiri
        }

        Vector3 pos = transform.position;

        // gerak Z
        pos.z += move * speed * Time.deltaTime;

        // 🔒 clamp batas Z
        pos.z = Mathf.Clamp(pos.z, minZ, maxZ);

        transform.position = pos;
    }
}