You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.4 KiB
56 lines
1.4 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using DG.Tweening;
|
|
public class doorCtrl : MonoBehaviour
|
|
{
|
|
// Start is called before the first frame update
|
|
public Transform top, bottom;
|
|
public float speed;
|
|
public float distance;
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
public void ToTop()
|
|
{
|
|
transform.DOKill();
|
|
transform.DOMove(top.position, (top.position-transform.position).magnitude/ speed);
|
|
}
|
|
public void ToBottom()
|
|
{
|
|
transform.DOKill();
|
|
transform.DOMove(bottom.position, (bottom.position - transform.position).magnitude / speed);
|
|
}
|
|
public void ToUp()
|
|
{
|
|
//transform.DOComplete();
|
|
transform.DOKill();
|
|
Vector3 Aim = transform.position + Vector3.up * distance;
|
|
if (Aim.y > top.position.y)
|
|
{
|
|
Aim = top.position;
|
|
}
|
|
|
|
transform.DOMove(Aim, (Aim - transform.position).magnitude / speed);
|
|
}
|
|
public void ToDown()
|
|
{
|
|
// transform.DOComplete();
|
|
transform.DOKill();
|
|
Vector3 Aim = transform.position - Vector3.up * distance;
|
|
if (Aim.y < bottom.position.y)
|
|
{
|
|
Aim = bottom.position;
|
|
}
|
|
transform.DOMove(Aim, (Aim-transform.position).magnitude / speed);
|
|
}
|
|
|
|
}
|