Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Mover : MonoBehaviour {
- // Calling the rail Script\\
- public Rail rail;
- //^ ^ \\
- private int currentSeg;
- private float transition;
- private bool isCompleted;
- private void Update()
- {
- if (!rail)
- return;
- if (!isCompleted)
- Play();
- }
- private void Play()
- {
- transition += Time.deltaTime * 1 / 0.45f;
- if(transition > 1)
- {
- transition = 0;
- currentSeg++;
- }
- else if(transition < 0)
- {
- transition = 1;
- currentSeg--;
- }
- transform.position = rail.LinearPosition(currentSeg, transition);
- // TEMPORARY DELETION transform.rotation = rail.Orientation(currentSeg, transition);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement