add train moving logic

This commit is contained in:
2022-11-12 01:52:31 +05:00
parent 6e2872c60d
commit ea7a810971
274 changed files with 40843 additions and 1440 deletions
+37
View File
@@ -0,0 +1,37 @@
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(0, 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));
}
}