2019-02-11 10:04:28 +00:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class AlignmentScript : MonoBehaviour
|
|
|
|
|
{
|
2019-02-11 10:40:07 +00:00
|
|
|
|
Transform shuttle;
|
|
|
|
|
Transform landing;
|
|
|
|
|
GameObject quad;
|
2019-02-11 10:04:28 +00:00
|
|
|
|
// Start is called before the first frame update
|
2019-02-11 10:40:07 +00:00
|
|
|
|
void Start() {
|
|
|
|
|
shuttle = GameObject.Find("ShuttleTarget").transform;
|
|
|
|
|
landing = GameObject.Find("LandingTarget").transform;
|
|
|
|
|
quad = GameObject.Find("AlignmentQuad");
|
2019-02-11 10:04:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
2019-02-11 10:40:07 +00:00
|
|
|
|
void Update() {
|
2019-02-11 10:04:28 +00:00
|
|
|
|
var upDot = Vector3.Dot(shuttle.up, landing.up);
|
|
|
|
|
var forwardDot = Vector3.Dot(shuttle.forward, landing.forward);
|
|
|
|
|
var ratio = (upDot + forwardDot) / 2;
|
|
|
|
|
var color = new Color((1 - ratio)*2, ratio, 0);
|
|
|
|
|
quad.GetComponent<Renderer>().material.color = color;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|