Files
cppk-ar/Assets/Scripts/Train.cs
T
2022-11-12 06:11:51 +05:00

38 lines
993 B
C#

using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
public class Train : MonoBehaviour
{
public TrainType type;
private LocomotionHandler locomotionHandler;
void OnEnable()
{
if(locomotionHandler == null)
locomotionHandler = FindObjectOfType<LocomotionHandler>();
var startPosition = locomotionHandler.pullUpPositionBefore;
var speed = locomotionHandler.trainSpeed;
transform.localPosition = new Vector3(transform.localPosition.x,
transform.localPosition.y,
startPosition);
transform.DOLocalMoveZ(-4, speed)
.SetEase(Ease.OutSine);
}
public void Hide()
{
var endPosition = locomotionHandler.pullUpPositionAfter;
var speed = locomotionHandler.trainSpeed;
transform.DOLocalMoveZ(endPosition, speed)
.SetEase(Ease.InSine)
.OnComplete(() => gameObject.SetActive(false));
}
}