├── ProjectSettings ├── AudioManager.asset ├── InputManager.asset ├── TagManager.asset ├── TimeManager.asset ├── EditorSettings.asset ├── NavMeshLayers.asset ├── NetworkManager.asset ├── DynamicsManager.asset ├── GraphicsSettings.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── QualitySettings.asset └── EditorBuildSettings.asset ├── Assets ├── SceneNodeSystem │ ├── Example │ │ ├── Simple.unity │ │ └── Simple.unity.meta │ ├── Example.meta │ ├── scripts.meta │ └── scripts │ │ ├── Editor.meta │ │ ├── nodeBehaviours.meta │ │ ├── nodeBehaviours │ │ ├── NodeBehaviour.cs │ │ ├── LoadScene.cs.meta │ │ ├── HideGameObject.cs.meta │ │ ├── NodeBehaviour.cs.meta │ │ ├── HideGameObject.cs │ │ └── LoadScene.cs │ │ ├── CameraNode.cs.meta │ │ ├── NodeCamera.cs.meta │ │ ├── Editor │ │ ├── CameraNodeToolbar.cs.meta │ │ ├── CameraNodeEditorData.cs.meta │ │ ├── CameraNodeInspector.cs.meta │ │ ├── CameraNodeEditorData.cs │ │ ├── CameraNodeToolbar.cs │ │ └── CameraNodeInspector.cs │ │ ├── CameraNode.cs │ │ └── NodeCamera.cs └── SceneNodeSystem.meta ├── .gitignore └── README.md /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/house/UnityTool_CameraNodes/master/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/house/UnityTool_CameraNodes/master/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/house/UnityTool_CameraNodes/master/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/house/UnityTool_CameraNodes/master/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/house/UnityTool_CameraNodes/master/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshLayers.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/house/UnityTool_CameraNodes/master/ProjectSettings/NavMeshLayers.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/house/UnityTool_CameraNodes/master/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/house/UnityTool_CameraNodes/master/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/house/UnityTool_CameraNodes/master/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/house/UnityTool_CameraNodes/master/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/house/UnityTool_CameraNodes/master/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/house/UnityTool_CameraNodes/master/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/house/UnityTool_CameraNodes/master/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /Assets/SceneNodeSystem/Example/Simple.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/house/UnityTool_CameraNodes/master/Assets/SceneNodeSystem/Example/Simple.unity -------------------------------------------------------------------------------- /Assets/SceneNodeSystem.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b6686fbac4b340948627c180615cf41 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/SceneNodeSystem/Example/Simple.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9dc9600632a3c4629b38aae680f0841e 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/SceneNodeSystem/Example.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9ff08fa36e5fc47ea93c1123d231e617 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/SceneNodeSystem/scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 81636a9a71cc242e29d9da92f2087702 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/SceneNodeSystem/scripts/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8c6cf707297934d6d852ab997c9f3b78 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/SceneNodeSystem/scripts/nodeBehaviours.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4732cf780a1994a32832a3e8bd53c539 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/SceneNodeSystem/scripts/nodeBehaviours/NodeBehaviour.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public abstract class NodeBehaviour : MonoBehaviour{ 4 | virtual public void OnEnterNode(){ 5 | } 6 | virtual public void OnLookAtNode(){ 7 | } 8 | } -------------------------------------------------------------------------------- /Assets/SceneNodeSystem/scripts/CameraNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 247a4c5e68d4b4833957af8105e36b3a 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/SceneNodeSystem/scripts/NodeCamera.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: afabf3c3083bd4f389d9e8f9d7e7294d 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/SceneNodeSystem/scripts/Editor/CameraNodeToolbar.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4e442d86961b7427f96da78e0899d778 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/SceneNodeSystem/scripts/nodeBehaviours/LoadScene.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2ad3a74a535524a419d88aee1a191cac 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/SceneNodeSystem/scripts/Editor/CameraNodeEditorData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6b1674a3fc9b8470b9016e0f363c4746 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/SceneNodeSystem/scripts/Editor/CameraNodeInspector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9d20cb4d0a9204bcb98287927d2cb91f 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/SceneNodeSystem/scripts/nodeBehaviours/HideGameObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 56df7542fa5ea4192a89cfdd1785eb49 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/SceneNodeSystem/scripts/nodeBehaviours/NodeBehaviour.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d73184a326614d7eb3dc2131305d6af 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/SceneNodeSystem/scripts/Editor/CameraNodeEditorData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEditor; 4 | public class CameraNodeEditorData 5 | { 6 | public CameraNode selectedNode = null; 7 | public CameraNodeEditorData () 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Assets/SceneNodeSystem/scripts/nodeBehaviours/HideGameObject.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class HideGameObject : NodeBehaviour { 5 | public GameObject objectToHide; 6 | override public void OnLookAtNode(){ 7 | objectToHide.SetActive (false); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Assets/SceneNodeSystem/scripts/CameraNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | public class CameraNode : MonoBehaviour { 7 | public List connectedNodes = new List(); 8 | public bool walkable = true; 9 | } 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /[Ll]ibrary/ 2 | /[Tt]emp/ 3 | /[Oo]bj/ 4 | /[Bb]uild/ 5 | 6 | # Autogenerated VS/MD solution and project files 7 | *.csproj 8 | *.unityproj 9 | *.sln 10 | *.suo 11 | *.tmp 12 | *.user 13 | *.userprefs 14 | *.pidb 15 | *.booproj 16 | 17 | # Unity3D generated meta files 18 | *.pidb.meta 19 | 20 | # Unity3D Generated File On Crash Reports 21 | sysinfo.txt -------------------------------------------------------------------------------- /Assets/SceneNodeSystem/scripts/nodeBehaviours/LoadScene.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | public class LoadScene : NodeBehaviour { 6 | public string levelName; 7 | void Start(){ 8 | DontDestroyOnLoad (gameObject); 9 | } 10 | override public void OnEnterNode(){ 11 | // unload the current level 12 | Application.LoadLevel(levelName); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Unity Tool: Camera Nodes 2 | 3 | A basic tool for creating myst style camera node navigation. Check the example file for a simple scene that uses it. 4 | 5 | For those that like watching videos, here is a quick demo: https://www.youtube.com/watch?v=XQDDzJ-wMoE (3mins) 6 | 7 | # HOWTO 8 | 9 | 1. Create a scene with a basic camera in it. 10 | 2. Attach the *Node Camera* script to the camera. 11 | 3. Create an empty game object, and attach the *Camera Node* script to it. This is also accessible through the Game Object / Camera Nodes / New Camera Node menu item. 12 | 5. Set the Camera Root Node on the *Node Camera* component to the first node in the scene. 13 | 6. While the node object is selected, you can click "Add Node" in the toolbar to add a new node that is walkable from this node. 14 | 7. In the inspector, the list of attached nodes is displayed. Pressing left moves the view to point at the node up the list, and pressing right moves down the list. Pressing up moves to the node that you are looking at if it is not set to walkable. 15 | 16 | ![Imgur](http://i.imgur.com/1qYKpQ2.png) 17 | 18 | # ADDITIONAL FEATURES 19 | 20 | You can create node behaviours to attach to nodes that operate when they are either looked at, or entered. There are examples of two of these in the scripts/NodeBehaviours directory. 21 | -------------------------------------------------------------------------------- /Assets/SceneNodeSystem/scripts/Editor/CameraNodeToolbar.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | using UnityEngine; 4 | public class CameraNodeToolbar 5 | { 6 | const int BOTTOM_TOOLBAR_HEIGHT = 20; 7 | public static CameraNodeEditorData editData; 8 | public void OnSceneGUI(SceneView sceneView){ 9 | Event e = Event.current; 10 | if (e.type == EventType.Repaint || e.type == EventType.Layout) 11 | { 12 | OnRepaint(sceneView, e); 13 | } 14 | } 15 | private static void OnRepaint(SceneView sceneView, Event e) 16 | { 17 | Rect rectangle = new Rect(0, sceneView.position.height - BOTTOM_TOOLBAR_HEIGHT, sceneView.position.width, BOTTOM_TOOLBAR_HEIGHT); 18 | 19 | GUIStyle style = new GUIStyle(EditorStyles.toolbar); 20 | style.fixedHeight = BOTTOM_TOOLBAR_HEIGHT; 21 | GUILayout.Window(0, rectangle, OnBottomToolbarGUI, "", style);//, EditorStyles.textField); 22 | } 23 | private static void OnBottomToolbarGUI(int windowID) 24 | { 25 | GUILayout.BeginHorizontal(); 26 | GUILayout.Label ("Camera Nodes"); 27 | if (editData.selectedNode != null) { 28 | if (GUILayout.Button ("Add Node")) { 29 | // create a new node 30 | GameObject newNode = new GameObject ("new node"); 31 | newNode.transform.position = editData.selectedNode.transform.position; 32 | CameraNode newCam = newNode.AddComponent (); 33 | editData.selectedNode.connectedNodes.Add (newCam); 34 | newCam.connectedNodes.Add (editData.selectedNode); 35 | newNode.transform.SetParent (editData.selectedNode.transform); 36 | Selection.activeGameObject = newNode; 37 | } 38 | editData.selectedNode.walkable = GUILayout.Toggle (editData.selectedNode.walkable, "walkable"); 39 | } 40 | GUILayout.FlexibleSpace (); 41 | GUILayout.EndHorizontal(); 42 | } 43 | private static bool CheckKeyPress(KeyCode toCheck, EventModifiers modifiers = EventModifiers.None, EventType eventType = EventType.KeyDown){ 44 | // Debug.Log (Event.current.keyCode + " " + Event.current.modifiers + " " + Event.current.type); 45 | return Event.current.type == eventType && Event.current.modifiers == modifiers && Event.current.keyCode == toCheck; 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /Assets/SceneNodeSystem/scripts/Editor/CameraNodeInspector.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using UnityEditorInternal; 6 | 7 | [CustomEditor(typeof(CameraNode))] 8 | public class CameraNodeInspector : Editor { 9 | Tool LastTool = Tool.None; 10 | float buttonSize = 0.04f; 11 | private const float handleSize = 0.04f; 12 | private const float pickSize = 0.06f; 13 | 14 | CameraNodeEditorData editData; 15 | CameraNodeToolbar toolbar; 16 | private ReorderableList list; 17 | [MenuItem("GameObject/Camera Nodes/New Camera Node", false, 10)] 18 | 19 | static void CreateCameraNode(MenuCommand menuCommand) { 20 | // Create a custom game object 21 | GameObject go = new GameObject("Camera Node"); 22 | CameraNode cameraNode = go.AddComponent (); 23 | // Ensure it gets reparented if this was a context click (otherwise does nothing) 24 | GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject); 25 | // Register the creation in the undo system 26 | Undo.RegisterCreatedObjectUndo(go, "Create " + go.name); 27 | Selection.activeObject = go; 28 | } 29 | 30 | void Awake(){ 31 | editData = new CameraNodeEditorData (); 32 | editData.selectedNode = target as CameraNode; 33 | CameraNodeToolbar.editData = editData; 34 | toolbar = new CameraNodeToolbar (); 35 | } 36 | void OnEnable(){ 37 | list = new ReorderableList(serializedObject, 38 | serializedObject.FindProperty("connectedNodes"), 39 | true, true, true, true); 40 | list.drawElementCallback = 41 | (Rect rect, int index, bool isActive, bool isFocused) => { 42 | var element = list.serializedProperty.GetArrayElementAtIndex(index); 43 | rect.y += 2; 44 | EditorGUI.ObjectField( 45 | new Rect(rect.x, rect.y, rect.width-30, EditorGUIUtility.singleLineHeight), 46 | element, GUIContent.none); 47 | }; 48 | 49 | if (toolbar == null) 50 | toolbar = new CameraNodeToolbar (); 51 | editData = new CameraNodeEditorData (); 52 | editData.selectedNode = target as CameraNode; 53 | CameraNodeToolbar.editData = editData; 54 | SceneView.onSceneGUIDelegate += toolbar.OnSceneGUI; 55 | } 56 | public override void OnInspectorGUI() { 57 | (target as CameraNode).walkable = GUILayout.Toggle ((target as CameraNode).walkable, "walkable"); 58 | serializedObject.Update(); 59 | list.DoLayoutList(); 60 | serializedObject.ApplyModifiedProperties(); 61 | } 62 | void OnDestroy() { 63 | // When the window is destroyed, remove the delegate 64 | // so that it will no longer do any drawing. 65 | SceneView.onSceneGUIDelegate -= toolbar.OnSceneGUI; 66 | } 67 | private void OnSceneGUI () { 68 | int controlID = GUIUtility.GetControlID (FocusType.Passive); 69 | CameraNode cameraNode = target as CameraNode; 70 | DrawCameraNode (cameraNode); 71 | } 72 | void DrawCameraNode(CameraNode root){ 73 | root.transform.position = Handles.DoPositionHandle (root.transform.position, Quaternion.identity); 74 | foreach (CameraNode cn in root.connectedNodes) { 75 | Handles.DrawDottedLine (root.transform.position, cn.transform.position, 1); 76 | Vector3 point = cn.transform.position; 77 | float size = HandleUtility.GetHandleSize(point); 78 | if(Handles.Button(cn.transform.position, Quaternion.identity, size*handleSize, size*pickSize, Handles.DotCap)){ 79 | // set this camera object as selected 80 | Selection.activeGameObject = cn.gameObject; 81 | } 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Assets/SceneNodeSystem/scripts/NodeCamera.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class NodeCamera : MonoBehaviour { 5 | public CameraNode cameraNodeRoot; 6 | public CameraNode currentNode; 7 | public int currentLookIndex = 0; 8 | Vector3 targetLookVector, currentLookVector; 9 | // Use this for initialization 10 | public bool moving = false; 11 | public bool allowTurn = true; 12 | IEnumerator visionMover; 13 | void Start () { 14 | SetNode (cameraNodeRoot); 15 | } 16 | Vector3 lookVectorToV3(Vector2 lookVector){ 17 | return new Vector3 (lookVector.x, 0, lookVector.y).normalized; 18 | } 19 | // Update is called once per frame 20 | void Update () { 21 | if (!currentNode) 22 | return; 23 | camera.transform.LookAt (currentLookVector, Vector3.up); 24 | if (Input.GetKeyDown (KeyCode.RightArrow) && allowTurn) { 25 | currentLookIndex = (currentLookIndex + 1) % currentNode.connectedNodes.Count; 26 | SetLookAt (currentLookIndex); 27 | } 28 | if (Input.GetKeyDown (KeyCode.LeftArrow) && allowTurn) { 29 | currentLookIndex = (currentLookIndex - 1); 30 | while (currentLookIndex < 0) 31 | currentLookIndex += currentNode.connectedNodes.Count; 32 | SetLookAt (currentLookIndex); 33 | } 34 | if (Input.GetKey (KeyCode.UpArrow) && currentNode.connectedNodes[currentLookIndex].walkable && !moving) { 35 | visionMover = MoveForward (); 36 | StartCoroutine (visionMover); 37 | } 38 | Debug.DrawLine (targetLookVector, currentNode.transform.position); 39 | currentLookVector = Vector3.Lerp (currentLookVector, targetLookVector, 5f*Time.deltaTime); 40 | } 41 | public void SetLookAt(int lookTarget, bool immediate = false){ 42 | currentLookIndex = lookTarget; 43 | targetLookVector = currentNode.connectedNodes[currentLookIndex].transform.position; 44 | if (immediate) 45 | currentLookVector = targetLookVector; 46 | // clear all existing text 47 | foreach (NodeBehaviour nb in currentNode.connectedNodes[currentLookIndex].GetComponents()) { 48 | nb.OnLookAtNode (); 49 | } 50 | } 51 | public void SetNode(CameraNode targetNode){ 52 | currentNode = cameraNodeRoot = targetNode; 53 | transform.position = currentNode.transform.position; 54 | targetLookVector = currentLookVector = cameraNodeRoot.connectedNodes[currentLookIndex].transform.position; 55 | } 56 | IEnumerator MoveForward(){ 57 | moving = true; 58 | Vector3 startPosition = transform.position; 59 | Vector3 targetPosition = currentNode.connectedNodes[currentLookIndex].transform.position; 60 | currentNode = currentNode.connectedNodes[currentLookIndex]; 61 | // find the nearest node to where we are already looking, and bind the camera to that 62 | Vector3 lookDirection = (targetPosition - startPosition).normalized; 63 | int lowestLookIndex = 0; 64 | float lowestLookDistance = -1*Vector3.Dot (lookDirection, (currentNode.connectedNodes[0].transform.position-currentNode.transform.position).normalized); 65 | for (int i = 0; i < currentNode.connectedNodes.Count; i++) { 66 | float lookDistance = -1*Vector3.Dot (lookDirection, (currentNode.connectedNodes[i].transform.position-currentNode.transform.position).normalized); 67 | if (lookDistance < lowestLookDistance) { 68 | lowestLookDistance = lookDistance; 69 | lowestLookIndex = i; 70 | } 71 | } 72 | SetLookAt (lowestLookIndex); 73 | foreach (NodeBehaviour nb in currentNode.GetComponents()) { 74 | nb.OnEnterNode (); 75 | } 76 | float startTime = Time.time; 77 | while (Time.time < startTime + 1.0f) { 78 | float percentage = Time.time - startTime; 79 | transform.position = Vector3.Lerp (startPosition, targetPosition, percentage); 80 | yield return new WaitForEndOfFrame (); 81 | } 82 | transform.position = targetPosition; 83 | moving = false; 84 | yield return null; 85 | } 86 | void OnLevelWasLoaded(int level) { 87 | moving = false; 88 | if(visionMover != null) 89 | StopCoroutine (visionMover); 90 | } 91 | } 92 | --------------------------------------------------------------------------------