aboutsummaryrefslogtreecommitdiff
path: root/Assets/Packages/RTS_Camera/Scripts
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Packages/RTS_Camera/Scripts')
-rw-r--r--Assets/Packages/RTS_Camera/Scripts/Editor.meta9
-rw-r--r--Assets/Packages/RTS_Camera/Scripts/Editor/LayoutHelpers.cs108
-rw-r--r--Assets/Packages/RTS_Camera/Scripts/Editor/LayoutHelpers.cs.meta12
-rw-r--r--Assets/Packages/RTS_Camera/Scripts/Editor/RTS_CameraEditor.cs158
-rw-r--r--Assets/Packages/RTS_Camera/Scripts/Editor/RTS_CameraEditor.cs.meta12
-rw-r--r--Assets/Packages/RTS_Camera/Scripts/RTS_Camera.cs344
-rw-r--r--Assets/Packages/RTS_Camera/Scripts/RTS_Camera.cs.meta12
7 files changed, 655 insertions, 0 deletions
diff --git a/Assets/Packages/RTS_Camera/Scripts/Editor.meta b/Assets/Packages/RTS_Camera/Scripts/Editor.meta
new file mode 100644
index 0000000..e25e69e
--- /dev/null
+++ b/Assets/Packages/RTS_Camera/Scripts/Editor.meta
@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: e5e4a28cbe8c55244bb1b72b33e5f8b6
+folderAsset: yes
+timeCreated: 1438769856
+licenseType: Store
+DefaultImporter:
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Packages/RTS_Camera/Scripts/Editor/LayoutHelpers.cs b/Assets/Packages/RTS_Camera/Scripts/Editor/LayoutHelpers.cs
new file mode 100644
index 0000000..2c41a09
--- /dev/null
+++ b/Assets/Packages/RTS_Camera/Scripts/Editor/LayoutHelpers.cs
@@ -0,0 +1,108 @@
+using UnityEngine;
+using System;
+using System.Collections.Generic;
+using UnityEditor;
+using System.Linq;
+
+
+public class VerticalBlock : IDisposable
+{
+ public VerticalBlock(params GUILayoutOption[] options)
+ {
+ GUILayout.BeginVertical(options);
+ }
+
+ public VerticalBlock(GUIStyle style, params GUILayoutOption[] options)
+ {
+ GUILayout.BeginVertical(style, options);
+ }
+
+ public void Dispose()
+ {
+ GUILayout.EndVertical();
+ }
+}
+
+public class ScrollviewBlock : IDisposable
+{
+ public ScrollviewBlock(ref Vector2 scrollPos, params GUILayoutOption[] options)
+ {
+ scrollPos = GUILayout.BeginScrollView(scrollPos, options);
+ }
+
+ public void Dispose()
+ {
+ GUILayout.EndScrollView();
+ }
+}
+
+public class HorizontalBlock : IDisposable
+{
+ public HorizontalBlock(params GUILayoutOption[] options)
+ {
+ GUILayout.BeginHorizontal(options);
+ }
+
+ public HorizontalBlock(GUIStyle style, params GUILayoutOption[] options)
+ {
+ GUILayout.BeginHorizontal(style, options);
+ }
+
+ public void Dispose()
+ {
+ GUILayout.EndHorizontal();
+ }
+}
+
+public class ColoredBlock : System.IDisposable
+{
+ public ColoredBlock(Color color)
+ {
+ GUI.color = color;
+ }
+
+ public void Dispose()
+ {
+ GUI.color = Color.white;
+ }
+}
+
+[Serializable]
+public class TabsBlock
+{
+ private Dictionary<string, Action> methods;
+ private Action currentGuiMethod;
+ public int curMethodIndex = -1;
+
+ public TabsBlock(Dictionary<string, Action> _methods)
+ {
+ methods = _methods;
+ SetCurrentMethod(0);
+ }
+
+ public void Draw()
+ {
+ var keys = methods.Keys.ToArray();
+ using (new VerticalBlock(EditorStyles.helpBox))
+ {
+ using (new HorizontalBlock())
+ {
+ for (int i = 0; i < keys.Length; i++)
+ {
+ var btnStyle = i == 0 ? EditorStyles.miniButtonLeft : i == (keys.Length - 1) ? EditorStyles.miniButtonRight : EditorStyles.miniButtonMid;
+ using (new ColoredBlock(currentGuiMethod == methods[keys[i]] ? Color.grey : Color.white))
+ if (GUILayout.Button(keys[i], btnStyle))
+ SetCurrentMethod(i);
+ }
+ }
+ GUILayout.Label(keys[curMethodIndex], EditorStyles.centeredGreyMiniLabel);
+ currentGuiMethod();
+ }
+ }
+
+ public void SetCurrentMethod(int index)
+ {
+ curMethodIndex = index;
+ currentGuiMethod = methods[methods.Keys.ToArray()[index]];
+ }
+} \ No newline at end of file
diff --git a/Assets/Packages/RTS_Camera/Scripts/Editor/LayoutHelpers.cs.meta b/Assets/Packages/RTS_Camera/Scripts/Editor/LayoutHelpers.cs.meta
new file mode 100644
index 0000000..07148cb
--- /dev/null
+++ b/Assets/Packages/RTS_Camera/Scripts/Editor/LayoutHelpers.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: e6604c54827307c4083b63203d4fed4b
+timeCreated: 1451938860
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Packages/RTS_Camera/Scripts/Editor/RTS_CameraEditor.cs b/Assets/Packages/RTS_Camera/Scripts/Editor/RTS_CameraEditor.cs
new file mode 100644
index 0000000..d4a828f
--- /dev/null
+++ b/Assets/Packages/RTS_Camera/Scripts/Editor/RTS_CameraEditor.cs
@@ -0,0 +1,158 @@
+using UnityEngine;
+using System.Collections.Generic;
+using UnityEditor;
+
+namespace RTS_Cam
+{
+ [CustomEditor(typeof(RTS_Camera))]
+ public class RTS_CameraEditor : Editor
+ {
+ private RTS_Camera camera { get { return target as RTS_Camera; } }
+
+ private TabsBlock tabs;
+
+ private void OnEnable()
+ {
+ tabs = new TabsBlock(new Dictionary<string, System.Action>()
+ {
+ {"Movement", MovementTab},
+ {"Rotation", RotationTab},
+ {"Height", HeightTab}
+ });
+ tabs.SetCurrentMethod(camera.lastTab);
+ }
+
+ public override void OnInspectorGUI()
+ {
+ //base.OnInspectorGUI();
+ Undo.RecordObject(camera, "RTS_CAmera");
+ tabs.Draw();
+ if (GUI.changed)
+ camera.lastTab = tabs.curMethodIndex;
+ EditorUtility.SetDirty(camera);
+ }
+
+ private void MovementTab()
+ {
+ using (new HorizontalBlock())
+ {
+ GUILayout.Label("Use keyboard input: ", EditorStyles.boldLabel, GUILayout.Width(170f));
+ camera.useKeyboardInput = EditorGUILayout.Toggle( camera.useKeyboardInput);
+ }
+ if(camera.useKeyboardInput)
+ {
+ camera.horizontalAxis = EditorGUILayout.TextField("Horizontal axis name: ", camera.horizontalAxis);
+ camera.verticalAxis = EditorGUILayout.TextField("Vertical axis name: ", camera.verticalAxis);
+ camera.keyboardMovementSpeed = EditorGUILayout.FloatField("Movement speed: ", camera.keyboardMovementSpeed);
+ }
+
+ using (new HorizontalBlock())
+ {
+ GUILayout.Label("Screen edge input: ", EditorStyles.boldLabel, GUILayout.Width(170f));
+ camera.useScreenEdgeInput = EditorGUILayout.Toggle( camera.useScreenEdgeInput);
+ }
+
+ if(camera.useScreenEdgeInput)
+ {
+ EditorGUILayout.FloatField("Screen edge border size: ", camera.screenEdgeBorder);
+ camera.screenEdgeMovementSpeed = EditorGUILayout.FloatField("Screen edge movement speed: ", camera.screenEdgeMovementSpeed);
+ }
+
+ using (new HorizontalBlock())
+ {
+ GUILayout.Label("Panning with mouse: ", EditorStyles.boldLabel, GUILayout.Width(170f));
+ camera.usePanning = EditorGUILayout.Toggle(camera.usePanning);
+ }
+ if(camera.usePanning)
+ {
+ camera.panningKey = (KeyCode)EditorGUILayout.EnumPopup("Panning when holding: ", camera.panningKey);
+ camera.panningSpeed = EditorGUILayout.FloatField("Panning speed: ", camera.panningSpeed);
+ }
+
+ using (new HorizontalBlock())
+ {
+ GUILayout.Label("Limit movement: ", EditorStyles.boldLabel, GUILayout.Width(170f));
+ camera.limitMap = EditorGUILayout.Toggle(camera.limitMap);
+ }
+ if (camera.limitMap)
+ {
+ camera.limitX = EditorGUILayout.FloatField("Limit X: ", camera.limitX);
+ camera.limitY = EditorGUILayout.FloatField("Limit Y: ", camera.limitY);
+ }
+
+ GUILayout.Label("Follow target", EditorStyles.boldLabel);
+ camera.targetFollow = EditorGUILayout.ObjectField("Target to follow: ", camera.targetFollow, typeof(Transform)) as Transform;
+ camera.targetOffset = EditorGUILayout.Vector3Field("Target offset: ", camera.targetOffset);
+ camera.followingSpeed = EditorGUILayout.FloatField("Following speed: ", camera.followingSpeed);
+ }
+
+ private void RotationTab()
+ {
+ using (new HorizontalBlock())
+ {
+ GUILayout.Label("Keyboard input: ", EditorStyles.boldLabel, GUILayout.Width(170f));
+ camera.useKeyboardRotation = EditorGUILayout.Toggle(camera.useKeyboardRotation);
+ }
+ if(camera.useKeyboardRotation)
+ {
+ camera.rotateLeftKey = (KeyCode)EditorGUILayout.EnumPopup("Rotate left: ", camera.rotateLeftKey);
+ camera.rotateRightKey = (KeyCode)EditorGUILayout.EnumPopup("Rotate right: ", camera.rotateRightKey);
+ camera.rotationSped = EditorGUILayout.FloatField("Keyboard rotation speed", camera.rotationSped);
+ }
+
+ using (new HorizontalBlock())
+ {
+ GUILayout.Label("Mouse input: ", EditorStyles.boldLabel, GUILayout.Width(170f));
+ camera.useMouseRotation = EditorGUILayout.Toggle(camera.useMouseRotation);
+ }
+ if(camera.useMouseRotation)
+ {
+ camera.mouseRotationKey = (KeyCode)EditorGUILayout.EnumPopup("Mouse rotation key: ", camera.mouseRotationKey);
+ camera.mouseRotationSpeed = EditorGUILayout.FloatField("Mouse rotation speed: ", camera.mouseRotationSpeed);
+ }
+ }
+
+ private void HeightTab()
+ {
+ using (new HorizontalBlock())
+ {
+ GUILayout.Label("Auto height: ", EditorStyles.boldLabel, GUILayout.Width(170f));
+ camera.autoHeight = EditorGUILayout.Toggle(camera.autoHeight);
+ }
+ if (camera.autoHeight)
+ {
+ camera.heightDampening = EditorGUILayout.FloatField("Height dampening: ", camera.heightDampening);
+ EditorGUILayout.PropertyField(serializedObject.FindProperty("groundMask"));
+ }
+
+ using (new HorizontalBlock())
+ {
+ GUILayout.Label("Keyboard zooming: ", EditorStyles.boldLabel, GUILayout.Width(170f));
+ camera.useKeyboardZooming = EditorGUILayout.Toggle(camera.useKeyboardZooming);
+ }
+ if(camera.useKeyboardZooming)
+ {
+ camera.zoomInKey = (KeyCode)EditorGUILayout.EnumPopup("Zoom In: ", camera.zoomInKey);
+ camera.zoomOutKey = (KeyCode)EditorGUILayout.EnumPopup("Zoom Out: ", camera.zoomOutKey);
+ camera.keyboardZoomingSensitivity = EditorGUILayout.FloatField("Keyboard sensitivity: ", camera.keyboardZoomingSensitivity);
+ }
+
+ using (new HorizontalBlock())
+ {
+ GUILayout.Label("Scrollwheel zooming: ", EditorStyles.boldLabel, GUILayout.Width(170f));
+ camera.useScrollwheelZooming = EditorGUILayout.Toggle(camera.useScrollwheelZooming);
+ }
+ if (camera.useScrollwheelZooming)
+ camera.scrollWheelZoomingSensitivity = EditorGUILayout.FloatField("Scrollwheel sensitivity: ", camera.scrollWheelZoomingSensitivity);
+
+ if (camera.useScrollwheelZooming || camera.useKeyboardZooming)
+ {
+ using (new HorizontalBlock())
+ {
+ camera.maxHeight = EditorGUILayout.FloatField("Max height: ", camera.maxHeight);
+ camera.minHeight = EditorGUILayout.FloatField("Min height: ", camera.minHeight);
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/Assets/Packages/RTS_Camera/Scripts/Editor/RTS_CameraEditor.cs.meta b/Assets/Packages/RTS_Camera/Scripts/Editor/RTS_CameraEditor.cs.meta
new file mode 100644
index 0000000..2c39be4
--- /dev/null
+++ b/Assets/Packages/RTS_Camera/Scripts/Editor/RTS_CameraEditor.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: f43923eb579b5ab44bc30687c03d3abe
+timeCreated: 1438769886
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Packages/RTS_Camera/Scripts/RTS_Camera.cs b/Assets/Packages/RTS_Camera/Scripts/RTS_Camera.cs
new file mode 100644
index 0000000..5e5ee76
--- /dev/null
+++ b/Assets/Packages/RTS_Camera/Scripts/RTS_Camera.cs
@@ -0,0 +1,344 @@
+using UnityEngine;
+using System.Collections;
+
+namespace RTS_Cam
+{
+ [RequireComponent(typeof(Camera))]
+ [AddComponentMenu("RTS Camera")]
+ public class RTS_Camera : MonoBehaviour
+ {
+
+ #region Foldouts
+
+#if UNITY_EDITOR
+
+ public int lastTab = 0;
+
+ public bool movementSettingsFoldout;
+ public bool zoomingSettingsFoldout;
+ public bool rotationSettingsFoldout;
+ public bool heightSettingsFoldout;
+ public bool mapLimitSettingsFoldout;
+ public bool targetingSettingsFoldout;
+ public bool inputSettingsFoldout;
+
+#endif
+
+ #endregion
+
+ private Transform m_Transform; //camera tranform
+ public bool useFixedUpdate = false; //use FixedUpdate() or Update()
+
+ #region Movement
+
+ public float keyboardMovementSpeed = 5f; //speed with keyboard movement
+ public float screenEdgeMovementSpeed = 3f; //spee with screen edge movement
+ public float followingSpeed = 5f; //speed when following a target
+ public float rotationSped = 3f;
+ public float panningSpeed = 10f;
+ public float mouseRotationSpeed = 10f;
+
+ #endregion
+
+ #region Height
+
+ public bool autoHeight = true;
+ public LayerMask groundMask = -1; //layermask of ground or other objects that affect height
+
+ public float maxHeight = 10f; //maximal height
+ public float minHeight = 15f; //minimnal height
+ public float heightDampening = 5f;
+ public float keyboardZoomingSensitivity = 2f;
+ public float scrollWheelZoomingSensitivity = 25f;
+
+ private float zoomPos = 0; //value in range (0, 1) used as t in Matf.Lerp
+
+ #endregion
+
+ #region MapLimits
+
+ public bool limitMap = true;
+ public float limitX = 50f; //x limit of map
+ public float limitY = 50f; //z limit of map
+
+ #endregion
+
+ #region Targeting
+
+ public Transform targetFollow; //target to follow
+ public Vector3 targetOffset;
+
+ /// <summary>
+ /// are we following target
+ /// </summary>
+ public bool FollowingTarget
+ {
+ get
+ {
+ return targetFollow != null;
+ }
+ }
+
+ #endregion
+
+ #region Input
+
+ public bool useScreenEdgeInput = true;
+ public float screenEdgeBorder = 25f;
+
+ public bool useKeyboardInput = true;
+ public string horizontalAxis = "Horizontal";
+ public string verticalAxis = "Vertical";
+
+ public bool usePanning = true;
+ public KeyCode panningKey = KeyCode.Mouse2;
+
+ public bool useKeyboardZooming = true;
+ public KeyCode zoomInKey = KeyCode.E;
+ public KeyCode zoomOutKey = KeyCode.Q;
+
+ public bool useScrollwheelZooming = true;
+ public string zoomingAxis = "Mouse ScrollWheel";
+
+ public bool useKeyboardRotation = true;
+ public KeyCode rotateRightKey = KeyCode.X;
+ public KeyCode rotateLeftKey = KeyCode.Z;
+
+ public bool useMouseRotation = true;
+ public KeyCode mouseRotationKey = KeyCode.Mouse1;
+
+ private Vector2 KeyboardInput
+ {
+ get { return useKeyboardInput ? new Vector2(Input.GetAxis(horizontalAxis), Input.GetAxis(verticalAxis)) : Vector2.zero; }
+ }
+
+ private Vector2 MouseInput
+ {
+ get { return Input.mousePosition; }
+ }
+
+ private float ScrollWheel
+ {
+ get { return Input.GetAxis(zoomingAxis); }
+ }
+
+ private Vector2 MouseAxis
+ {
+ get { return new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y")); }
+ }
+
+ private int ZoomDirection
+ {
+ get
+ {
+ bool zoomIn = Input.GetKey(zoomInKey);
+ bool zoomOut = Input.GetKey(zoomOutKey);
+ if (zoomIn && zoomOut)
+ return 0;
+ else if (!zoomIn && zoomOut)
+ return 1;
+ else if (zoomIn && !zoomOut)
+ return -1;
+ else
+ return 0;
+ }
+ }
+
+ private int RotationDirection
+ {
+ get
+ {
+ bool rotateRight = Input.GetKey(rotateRightKey);
+ bool rotateLeft = Input.GetKey(rotateLeftKey);
+ if(rotateLeft && rotateRight)
+ return 0;
+ else if(rotateLeft && !rotateRight)
+ return -1;
+ else if(!rotateLeft && rotateRight)
+ return 1;
+ else
+ return 0;
+ }
+ }
+
+ #endregion
+
+ #region Unity_Methods
+
+ private void Start()
+ {
+ m_Transform = transform;
+ }
+
+ private void Update()
+ {
+ if (!useFixedUpdate)
+ CameraUpdate();
+ }
+
+ private void FixedUpdate()
+ {
+ if (useFixedUpdate)
+ CameraUpdate();
+ }
+
+ #endregion
+
+ #region RTSCamera_Methods
+
+ /// <summary>
+ /// update camera movement and rotation
+ /// </summary>
+ private void CameraUpdate()
+ {
+ if (FollowingTarget)
+ FollowTarget();
+ else
+ Move();
+
+ HeightCalculation();
+ Rotation();
+ LimitPosition();
+ }
+
+ /// <summary>
+ /// move camera with keyboard or with screen edge
+ /// </summary>
+ private void Move()
+ {
+ if (useKeyboardInput)
+ {
+ Vector3 desiredMove = new Vector3(KeyboardInput.x, 0, KeyboardInput.y);
+
+ desiredMove *= keyboardMovementSpeed;
+ desiredMove *= Time.deltaTime;
+ desiredMove = Quaternion.Euler(new Vector3(0f, transform.eulerAngles.y, 0f)) * desiredMove;
+ desiredMove = m_Transform.InverseTransformDirection(desiredMove);
+
+ m_Transform.Translate(desiredMove, Space.Self);
+ }
+
+ if (useScreenEdgeInput)
+ {
+ Vector3 desiredMove = new Vector3();
+
+ Rect leftRect = new Rect(0, 0, screenEdgeBorder, Screen.height);
+ Rect rightRect = new Rect(Screen.width - screenEdgeBorder, 0, screenEdgeBorder, Screen.height);
+ Rect upRect = new Rect(0, Screen.height - screenEdgeBorder, Screen.width, screenEdgeBorder);
+ Rect downRect = new Rect(0, 0, Screen.width, screenEdgeBorder);
+
+ desiredMove.x = leftRect.Contains(MouseInput) ? -1 : rightRect.Contains(MouseInput) ? 1 : 0;
+ desiredMove.z = upRect.Contains(MouseInput) ? 1 : downRect.Contains(MouseInput) ? -1 : 0;
+
+ desiredMove *= screenEdgeMovementSpeed;
+ desiredMove *= Time.deltaTime;
+ desiredMove = Quaternion.Euler(new Vector3(0f, transform.eulerAngles.y, 0f)) * desiredMove;
+ desiredMove = m_Transform.InverseTransformDirection(desiredMove);
+
+ m_Transform.Translate(desiredMove, Space.Self);
+ }
+
+ if(usePanning && Input.GetKey(panningKey) && MouseAxis != Vector2.zero)
+ {
+ Vector3 desiredMove = new Vector3(-MouseAxis.x, 0, -MouseAxis.y);
+
+ desiredMove *= panningSpeed;
+ desiredMove *= Time.deltaTime;
+ desiredMove = Quaternion.Euler(new Vector3(0f, transform.eulerAngles.y, 0f)) * desiredMove;
+ desiredMove = m_Transform.InverseTransformDirection(desiredMove);
+
+ m_Transform.Translate(desiredMove, Space.Self);
+ }
+ }
+
+ /// <summary>
+ /// calcualte height
+ /// </summary>
+ private void HeightCalculation()
+ {
+ float distanceToGround = DistanceToGround();
+ if(useScrollwheelZooming)
+ zoomPos += ScrollWheel * Time.deltaTime * scrollWheelZoomingSensitivity;
+ if (useKeyboardZooming)
+ zoomPos += ZoomDirection * Time.deltaTime * keyboardZoomingSensitivity;
+
+ zoomPos = Mathf.Clamp01(zoomPos);
+
+ float targetHeight = Mathf.Lerp(minHeight, maxHeight, zoomPos);
+ float difference = 0;
+
+ if(distanceToGround != targetHeight)
+ difference = targetHeight - distanceToGround;
+
+ m_Transform.position = Vector3.Lerp(m_Transform.position,
+ new Vector3(m_Transform.position.x, targetHeight + difference, m_Transform.position.z), Time.deltaTime * heightDampening);
+ }
+
+ /// <summary>
+ /// rotate camera
+ /// </summary>
+ private void Rotation()
+ {
+ if(useKeyboardRotation)
+ transform.Rotate(Vector3.up, RotationDirection * Time.deltaTime * rotationSped, Space.World);
+
+ if (useMouseRotation && Input.GetKey(mouseRotationKey))
+ m_Transform.Rotate(Vector3.up, -MouseAxis.x * Time.deltaTime * mouseRotationSpeed, Space.World);
+ }
+
+ /// <summary>
+ /// follow targetif target != null
+ /// </summary>
+ private void FollowTarget()
+ {
+ Vector3 targetPos = new Vector3(targetFollow.position.x, m_Transform.position.y, targetFollow.position.z) + targetOffset;
+ m_Transform.position = Vector3.MoveTowards(m_Transform.position, targetPos, Time.deltaTime * followingSpeed);
+ }
+
+ /// <summary>
+ /// limit camera position
+ /// </summary>
+ private void LimitPosition()
+ {
+ if (!limitMap)
+ return;
+
+ m_Transform.position = new Vector3(Mathf.Clamp(m_Transform.position.x, -limitX, limitX),
+ m_Transform.position.y,
+ Mathf.Clamp(m_Transform.position.z, -limitY, limitY));
+ }
+
+ /// <summary>
+ /// set the target
+ /// </summary>
+ /// <param name="target"></param>
+ public void SetTarget(Transform target)
+ {
+ targetFollow = target;
+ }
+
+ /// <summary>
+ /// reset the target (target is set to null)
+ /// </summary>
+ public void ResetTarget()
+ {
+ targetFollow = null;
+ }
+
+ /// <summary>
+ /// calculate distance to ground
+ /// </summary>
+ /// <returns></returns>
+ private float DistanceToGround()
+ {
+ Ray ray = new Ray(m_Transform.position, Vector3.down);
+ RaycastHit hit;
+ if (Physics.Raycast(ray, out hit, groundMask.value))
+ return (hit.point - m_Transform.position).magnitude;
+
+ return 0f;
+ }
+
+ #endregion
+ }
+} \ No newline at end of file
diff --git a/Assets/Packages/RTS_Camera/Scripts/RTS_Camera.cs.meta b/Assets/Packages/RTS_Camera/Scripts/RTS_Camera.cs.meta
new file mode 100644
index 0000000..70a41e8
--- /dev/null
+++ b/Assets/Packages/RTS_Camera/Scripts/RTS_Camera.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 28ef8c68bade09b41aca258d42a632f2
+timeCreated: 1438769867
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: