advancedskrald/ChessAR/Assets/AlignmentScript.cs

27 lines
836 B
C#
Raw Permalink Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AlignmentScript : MonoBehaviour
{
Transform shuttle;
Transform landing;
GameObject quad;
// Start is called before the first frame update
void Start() {
shuttle = GameObject.Find("ShuttleTarget").transform;
landing = GameObject.Find("LandingTarget").transform;
quad = GameObject.Find("AlignmentQuad");
}
// Update is called once per frame
void Update() {
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;
}
}