arskrald/AR-1/Assets/AlignmentScript.cs

33 lines
951 B
C#

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