public Connection (Node s,Node e) {
			startNode = s;
			endNode = e;
		}
		public Connection (Node e,int c,float a,bool en) {
			endNode = e;
			cost = c;
			angle = a;
			enabled = en;
		}
		/*public int g {
			get {
				if (parent == null) {//Does this node have a parent?
					return 0;
				}
				
				//AstarPath.gCalls++;
				
				//@Performance, uncomment the next IF (and 'parentx = parent') to get better performance but at a cost of lower accuracy
				
				if (parent == parentx) {
					return _g;
				} else {
					parentx = parent;
					
					//Trace back to the starting point
					_g = basicCost+extraCost+penalty+parent.g;
				}
				
				return _g;
			}
		}*/
		
		public void UpdateH (Node end) {
			//If useWorldPositions is True, then the script will calculate the distance between this node and the target using world positions, otherwise it will use the array indexes (grids are made up of 2D arrays), which is a lot faster since it only uses integers instead of floats. It is recommended to use world positions when not using the Grid or Texture mode since all other modes does not place the nodes in an array which indexes can be used as positions.
			//It can also be good to use world positions when using multiple grids since the array indexes wont create a good direction when this node and the target node are in different grids.
					
			if (AstarPath.active.useWorldPositions) {
				
				h = (int) (Mathf.Abs(end.vectorPos.x-vectorPos.x)*10
			
				+  Mathf.Abs(end.vectorPos.y-vectorPos.y)*10
			
				+ Mathf.Abs(end.vectorPos.z-vectorPos.z)*10);
				
			} else {
				
				h = Mathf.Abs(end.pos.x-pos.x)*10
			
				//@Performance, comment out the next line if you dont use multiple grids
				+ Mathf.Abs((int)AstarPath.active.grids[end.pos.y].offset.y-(int)AstarPath.active.grids[pos.y].offset.y)*AstarPath.active.levelCost
			
				+ Mathf.Abs(end.pos.z-pos.z)*10;
				
				//This is another heuristic, try it if you want
				/*int xDistance = Mathf.Abs(script.end.pos.x-pos.x);
				int zDistance = Mathf.Abs(script.end.pos.z-pos.z);
				if (xDistance > zDistance) {
				     hx = 14*zDistance + 10*(xDistance-zDistance);
				} else {
				     hx = 14*xDistance + 10*(zDistance-xDistance);
				}*/
			}
		}
		public Node (Node o) {//Copy
			walkable = o.walkable;
			vectorPos = o.vectorPos;
			pos = o.pos;
		}
		public virtual void Open (AstarPath.BinaryHeap open, AstarPath.Path p, Node start, Node end, float angleCost) {
			
			for (int i=0;i<enabledConnections.Length;i++) {
				
				Connection connection = enabledConnections[i];
				Node node = connection.endNode;
				
				if (node == start) {
					continue;
				}
				
				//Debug.DrawLine (current.vectorPos,current.neighbours[i].vectorPos,Color.red); //Uncomment for debug
				//If the nodes script variable isn't refering to this path class the node counts as "not used yet" and can then be used
				if (node.script != p) {
					//Test if the angle from the current node to this one has exceded the angle limit
					//if (angle >= maxAngle) {
					//	return;
					//}
					node.parent = this;
					node.script = p;
					
					node.basicCost = connection.cost + Mathf.RoundToInt (connection.cost*connection.angle*angleCost);
					//(current.costs == null || costs.Length == 0 ? costs[node.invParentDirection] : current.costs[node.invParentDirection]);
					//Calculate the extra cost of moving in a slope
					//node.extraCost =  ;
					//Add the node to the open array
					//Debug.DrawLine (current.vectorPos,current.neighbours[i].vectorPos,Color.green); //Uncomment for @Debug
					
					node.UpdateH (end);
					node.UpdateG ();
					
					open.Add (node);
					
				} else {
					
					//If not we can test if the path from the current node to this one is a better one then the one already used
					int cost2 = connection.cost + Mathf.RoundToInt (connection.cost*connection.angle*angleCost);//(current.costs == null || current.costs.Length == 0 ? costs[current.neighboursKeys[i]] : current.costs[current.neighboursKeys[i]]);
					
					//int extraCost2
					
					if (g+cost2+node.penalty < node.g) {
						node.basicCost = cost2;
						//node.extraCost = extraCost2;
						node.parent = this;
						
						node.UpdateAllG ();
						
						open.Add (node);//@Quality, uncomment for better quality (I think).
						
						//Debug.DrawLine (current.vectorPos,current.neighbours[i].vectorPos,Color.cyan); //Uncomment for @Debug
					}
					
					 else if (node.g+cost2+penalty < g) {//Or if the path from this node ("node") to the current ("current") is better
						bool contains = false;
						
						//Make sure we don't travel along the wrong direction of a one way link now, make sure the Current node can be accesed from the Node.
						for (int y=0;y<node.connections.Length;y++) {
							if (node.connections[y].endNode == this) {
								contains = true;
								break;
							}
						}
						
						if (!contains) {
							continue;
						}
						
						parent = node;
						basicCost = cost2;
						//extraCost = extraCost2;
						
						node.UpdateAllG ();
						
						//Debug.DrawLine (current.vectorPos,current.neighbours[i].vectorPos,Color.blue); //Uncomment for @Debug
						open.Add (this);
					}
				}
			}
		}
		public SerializedNode (Node node) {
			
			vectorPos = node.vectorPos;
			pos = node.pos;
			walkable = node.walkable;
			penalty = node.penalty;
			area = node.area;
			
			
		}
		public Edge(Vector3 endPointA, Vector3 endPointB, Node node)
		{
			this.endPointA = endPointA;
			this.endPointB = endPointB;
			edgeVector3D = endPointB - endPointA;
			this.edgeVector = new Vector2(edgeVector3D.x, edgeVector3D.z);
			this.node = node;
		}
		public static bool Contains (Node[] arr,Node target) {
			for (int i=0;i<arr.Length;i++) {
				if (arr[i] == target) {
					return true;
				}
			}
			return false;
		}
		public Node (Node o) {//Copy
			walkable = o.walkable;
			vectorPos = o.vectorPos;
			pos = o.pos;
			angles = o.angles;
			neighbours = o.neighbours;
		}