quality-control/Assets/Scripts/SlidingCrane.cs

33 lines
831 B
C#
Raw Normal View History

2024-08-17 11:38:26 +00:00
using Nothke.Utils;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SlidingCrane : MonoBehaviour
{
public InertialInterpolator xMotion = InertialInterpolator.Default();
public InertialInterpolator yMotion = InertialInterpolator.Default();
public Transform xTransform;
public Transform yTransform;
public float yRange = 10;
public float xRange = 5;
void Start()
{
yMotion.AccelerateTo(1);
xMotion.AccelerateTo(1);
}
// Update is called once per frame
void Update()
{
xMotion.Update(Time.deltaTime);
yMotion.Update(Time.deltaTime);
yTransform.localPosition = new Vector3(0, 0, yMotion.progress * yRange);
xTransform.localPosition = new Vector3(xMotion.progress * xRange, 0, 0);
}
}