SpotlightFollow.cs 738 B

12345678910111213141516171819202122
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. /// <summary>
  5. /// Causes the attached object to follow the target object but only on the X and Z axes: keeps its height.
  6. /// Used for the spotlight and view screen in the ZED MR Calibration scene.
  7. /// </summary>
  8. public class SpotlightFollow : MonoBehaviour
  9. {
  10. /// <summary>
  11. /// Transform that this object will follow on the X and Z axes.
  12. /// </summary>
  13. [Tooltip("Transform that this object will follow on the X and Z axes. ")]
  14. public Transform followTransform;
  15. void Update ()
  16. {
  17. transform.position = new Vector3(followTransform.position.x, transform.position.y, followTransform.position.z);
  18. }
  19. }