Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
643 B
2
Indexable
Never
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class winda : MonoBehaviour
{
    public int height = 3;
    private Vector3 poz1;
    private Vector3 poz2;
    private Vector3 poz;
    void Start()
    {
        poz1 = transform.position;
        poz2 = poz1;
        poz2.y += height;
        poz.x = 0;
        poz.y = 0.001f;
        poz.z = 0;
    }
    void Update()
    {
        if (transform.position.y > poz2.y)
        {
            poz.y = -0.001f;
        }
        if (transform.position.y < poz1.y)
        {
            poz.y = 0.001f;
        }
        transform.position += poz;
    }
}