public void OnDrawDebug() { #if DEBUG Vector3 position = Vector3.zero; GetPosition(ref position); GLRenderingUtils.DoDrawLine(_gameCameraLookAt, position, Color.green); GLRenderingUtils.DoDrawSphere(_gameCameraLookAt, 0.8f, Color.yellow); GLRenderingUtils.DoDrawSphere(position, 0.8f, Color.red); #endif }
public void OnDrawDebug() { if (!drawDebug || (AmILocal() && !fakeLocalDebugging)) { return; } const float SphereRad = 0.3f; GLRenderingUtils.DoDrawSphere(_hostPosition, SphereRad * 0.3f, Color.green); const float AxisScale = 1.5f; GLRenderingUtils.DoDrawScaledAxes(_hostRotation, _hostPosition, AxisScale); int trans = Mathf.Max(0, _networkTransforms.Count - maxNetworkTransformsToDraw); // don't draw more network transforms than required for (; trans < _networkTransforms.Count; ++trans) { if (!drawFutureUpdatesInLoopMode && loopMode && CalculateLoopModeTime() < _networkTransforms[trans].time) { break; } NetworkTransform temp = _networkTransforms[trans]; GLRenderingUtils.DoDrawSphere(temp.position, SphereRad, Color.red); // draw the position of this network transform GLRenderingUtils.DoDrawLine(temp.position, temp.position + temp.predictedVelocity * GetNetworkUpdateInterval(), Color.green); // draw a line from this network transform position to predicted velocity end GLRenderingUtils.DoDrawSphere(temp.position + temp.predictedVelocity * GetNetworkUpdateInterval(), SphereRad * 0.5f, Color.yellow); // draw a line at the end of the predicted velocity GLRenderingUtils.DoDrawSphere(temp.extrapolatedPosition, SphereRad * 0.5f, Color.blue); // where hs the position been extrapolated to upto now if (trans > 0) { NetworkTransform prev = _networkTransforms[trans - 1]; GLRenderingUtils.DoDrawLine(temp.position, prev.position, Color.white); // draw a line to the previous network update position } } }
private void DrawNodeCosts() { if (doDrawNodeCosts) { PlayerController player = PlayerManager.LocalPlayerController(); if (null != player) { NNInfo info = AstarPath.active.GetNearest(player.GetComponent <LocomotionComponentAPP>().Destination); TriangleMeshNode node = info.node as TriangleMeshNode; if (null != node) { for (int i = 0; i < 3; ++i) { int next = (i + 1) % 3; Vector3 one = (Vector3)node.GetVertex(i); Vector3 two = (Vector3)node.GetVertex(next); GLRenderingUtils.DoDrawLine(one, two, Color.white); } int highestConnectionCostIndex = 0; for (int connect = 1; connect < node.connections.Length; ++connect) { if (node.connectionCosts[connect] > node.connectionCosts[highestConnectionCostIndex]) { highestConnectionCostIndex = connect; } } Color[] colors = new Color[] { Color.red, Color.green, Color.blue }; string[] colorNames = new string[] { "Color.red", "Color.green", "Color.blue" }; const float HeightOffset = 2f; for (int connect = 0; connect < node.connections.Length; ++connect) { TriangleMeshNode nodeConnect = node.connections[connect] as TriangleMeshNode; GLRenderingUtils.DoDrawLine((Vector3)node.position, (Vector3)nodeConnect.position, colors[Mathf.Min(connect, colors.Length - 1)]); float dist = GameUtils.SubXZ((Vector3)node.position, (Vector3)nodeConnect.position).magnitude; Vector3 offset = new Vector3(0f, ((float)node.connectionCosts[connect] / (float)node.connectionCosts[highestConnectionCostIndex]) * HeightOffset, 0f); for (int i = 0; i < 3; ++i) { int next = (i + 1) % 3; Vector3 one = (Vector3)nodeConnect.GetVertex(i); Vector3 two = (Vector3)nodeConnect.GetVertex(next); Vector3 oneOffset = one + offset; Vector3 twoOffset = two + offset; Color col = colors[Mathf.Min(connect, colors.Length - 1)]; GLRenderingUtils.DoDrawLine(oneOffset, twoOffset, col); GLRenderingUtils.DoDrawLine(one, oneOffset, col); GLRenderingUtils.DoDrawLine(two, twoOffset, col); } if (doPrintNodeCosts) { DebugSystem.Log(colorNames[Mathf.Min(connect, colorNames.Length - 1)] + ": Cost: " + node.connectionCosts[connect] + " Dist: " + dist, "Pathfinding"); } } } } } doPrintNodeCosts = false; }