PivotBasedCameraRig.cs 787 B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using UnityEngine;
  3. namespace UnityStandardAssets.Cameras
  4. {
  5. public abstract class PivotBasedCameraRig : AbstractTargetFollower
  6. {
  7. // This script is designed to be placed on the root object of a camera rig,
  8. // comprising 3 gameobjects, each parented to the next:
  9. // Camera Rig
  10. // Pivot
  11. // Camera
  12. protected Transform m_Cam; // the transform of the camera
  13. protected Transform m_Pivot; // the point at which the camera pivots around
  14. protected Vector3 m_LastTargetPosition;
  15. protected virtual void Awake()
  16. {
  17. // find the camera in the object hierarchy
  18. m_Cam = GetComponentInChildren<Camera>().transform;
  19. m_Pivot = m_Cam.parent;
  20. }
  21. }
  22. }