Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- // using UnityEditor;
- [ExecuteInEditMode]
- public class Rail : MonoBehaviour
- {
- private Transform[] nodes;
- private void Start()
- {
- nodes = GetComponentsInChildren<Transform>();
- }
- public Vector3 LinearPosition(int seg, float ratio)
- {
- Vector3 p1 = nodes[seg].position;
- Vector3 p2 = nodes[seg + 1].position;
- Vector3 p3 = nodes[seg+ 2].position;
- return Vector3.Lerp(p1, p2, ratio);
- }
- public Quaternion Orientation(int seg, float ratio)
- {
- Quaternion q1 = nodes[seg].rotation;
- Quaternion q2 = nodes[seg + 1].rotation;
- return Quaternion.Lerp(q1, q2, ratio); }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement