title: Affecting an object's position through another object's rotation in Unity
body: <p>I have a floating gameobject (brickRot) that looks at what object is beneath it through a raycast, and then changes that object's y-position (floorY) based on brickRot's rotation. However, I'm having trouble converting rotation into a useful metric for changing Y-position. I want the current rotation of brickRot to be equal to whatever the y-position of floorY is, and then only change relative to the rotation of brickRot (if that makes any sense).</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class FloorRotation : MonoBehaviour {
  
  private float brickRot;
  private float floorY;
  
  void Update () {
      brickRot = transform.rotation.y;
  
      RaycastHit hit;
      Ray floorRay = new Ray(transform.position, Vector3.down);
  
      if(Physics.Raycast(floorRay, out hit)) {
          if(hit.collider.tag == "floor") {
              floorY = hit.transform.position.y;
              floorY = floorY + brickRot;
              Debug.Log(floorY);
          }
      }
    }
  }
  </code></pre>
  
  <p>Think of brickRot as a plate you put down on the table, and when you rotate the plate, you change the table's y-position (if that analogy makes it any less confusing). The reason why I'm using a raycast is because there are multiple "tables" that the brick can find, and it needs to differentiate between them. If anyone has an idea of how to make this any easier, I would be forever thankful!</p>