//Detect collisions between the GameObjects with Colliders attached private void OnTriggerStay(Collider other) { //Check for a match with the specified name on any GameObject that collides with your GameObject if (other.gameObject.name.StartsWith("Floor")) { ontheFloor = other.gameObject.GetComponent <NodeMono>(); } }
public override void OnInspectorGUI() { if (m_Graph.transform.childCount > 0) { m_Graph.nodes.Clear(); foreach (Transform child in m_Graph.transform) { NodeMono node = child.GetComponent <NodeMono>(); if (node != null) { node.UpdateList(); m_Graph.nodes.Add(node.MyNode); } } } base.OnInspectorGUI(); EditorGUILayout.Separator(); m_From = (NodeMono)EditorGUILayout.ObjectField("From", m_From, typeof(NodeMono), true); m_To = (NodeMono)EditorGUILayout.ObjectField("To", m_To, typeof(NodeMono), true); m_Follower = (Follower)EditorGUILayout.ObjectField("Follower", m_Follower, typeof(Follower), true); if (GUILayout.Button("Show Shortest Path")) { if (m_From == null || m_To == null) { m_Path = m_Graph.findFromNodesGiven(); } else { m_Path = m_Graph.GetShortestPath(m_From.MyNode, m_To.MyNode); } if (m_Follower != null) { m_Follower.Follow(m_Path); } Debug.Log(m_Path); SceneView.RepaintAll(); } }
private IEnumerator waitAbit(UnityEngine.UI.Button button) { yield return(null); button.interactable = true; float dist = 0; float tempDist = 0; GameObject target = null; for (int i = 0; i < allTargets.Count; i++) { tempDist = Vector3.Distance(Vector3.zero, allTargets[i].transform.position); if (dist <= tempDist) { dist = tempDist; target = allTargets[i]; } } for (int i = 0; i < allTargets.Count; i++) { if (target != allTargets[i]) { Destroy(allTargets[i]); } } allTargets.Clear(); allTargets.Add(target); var newOne = target.transform.position; int row = (int)(newOne.z / ZfloatDistanceCellHeight); // heaight int colums = (int)(newOne.x / XfloatDistanceCellWidth); // widht var mazeCell = wholeMaze[row, colums]; endGoal = mazeCell.myMonoCell; isReady = true; }