U3D_TobaccoWarehouseISMDTSy.../Assets/Scripts/YL/Boxcoder.cs

27 lines
747 B
C#

using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Boxcoder : MonoBehaviour
{
public Transform Points;
public float speed = 3.5f;
void OnTriggerStay(Collider other)
{
if (other.gameObject.CompareTag("Box"))
{
if (Points.childCount == 0)
{
GameObject game = other.gameObject;
game.transform.SetParent(null);
game.transform.DOMove(Points.position, (Vector3.Distance(game.transform.position, Points.position) / speed)).SetEase(Ease.InOutQuad).OnComplete(() =>
{
game.transform.SetParent(Points);
});
}
}
}
}