UnityEngine.Debug.DrawLine(UnityEngine.Vector3, UnityEngine.Vector3)

Here are the examples of the csharp api UnityEngine.Debug.DrawLine(UnityEngine.Vector3, UnityEngine.Vector3) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

12 Examples 7

19 View Source File : AnimalMovement.cs
License : MIT License
Project Creator : Interactml

protected void RayCasting()
        {
            if (AnimState != AnimTag.Jump
                && AnimState != AnimTag.JumpEnd
                && AnimState != AnimTag.Recover
                && AnimState != AnimTag.Fall)
            {
                if (FrameCounter % PivotsRayInterval != 0) return;         //Skip to reduce aditional raycasting
            }

            if (underwater) return;

            UpVector = -Physics.gravity;
            scaleFactor = _transform.localScale.y;                       //Keep Updating the Scale Every Frame
            _Height = height * scaleFactor;                              //multiply the Height by the scale

            backray = frontray = false;

            hit_Chest = NULLRayCast;                               //Clean the Raycasts every time 
            hit_Hip = NULLRayCast;                                 //Clean the Raycasts every time 

            hit_Chest.distance = hit_Hip.distance = _Height;       //Reset the Distances to the Heigth of the animal (IMPORTANT)

            if (Pivot_Hip != null) //Ray From the Hip to the ground
            {
                if (Physics.Raycast(Pivot_Hip.GetPivot, -T_Up, out hit_Hip, scaleFactor * Pivot_Hip.multiplier, GroundLayer))
                {
                    if (debug) Debug.DrawRay(hit_Hip.point, hit_Hip.normal * 0.2f, Color.blue);

                    float BackSlopeAngle = Vector3.Angle(hit_Hip.normal, Vector3.up);

                    if (BackSlopeAngle < maxAngleSlope)

                    {
                        backray = true;

                        if (Platform == null && AnimState != AnimTag.Jump)               //Platforming logic
                        {
                            Platform = hit_Hip.transform;
                            platform_Pos = Platform.position;
                            platform_formAngle = Platform.eulerAngles.y;
                        }
                        CheckForLanding();
                    }
                }
                else { Platform = null; }
            }

            //Ray From Chest to the ground ***Use the pivot for calculate the ray... but the origin position to calculate the distance
            if (Physics.Raycast(Main_Pivot_Point, -T_Up, out hit_Chest, Pivot_Multiplier, GroundLayer))
            {
                if (debug) Debug.DrawRay(hit_Chest.point, hit_Chest.normal * 0.2f, Color.red);

                float frontSlopeAngle = Vector3.Angle(hit_Chest.normal, Vector3.up);

                if (frontSlopeAngle < maxAngleSlope) frontray = true;

                CheckForLanding();
            }

            if (debug && frontray && backray)
            {
                Debug.DrawLine(hit_Hip.point, hit_Chest.point, Color.yellow);
            }

            if (!frontray && Stand) //Hack if is there's no ground beneath the animal and is on the Stand Sate;
            {
                fall = true;

                if (pivot_Hip && backray) fall = false;
            }

            FixDistance = hit_Hip.distance;
            if (!backray) FixDistance = hit_Chest.distance;         //if is landing on the front feets


            if (!Pivot_Hip) backray = frontray;    //In case there's no backray
            if (!Pivot_Chest) frontray = backray;    //In case there's no frontRay
        }

19 View Source File : JumpBehaviour.cs
License : MIT License
Project Creator : Interactml

void Can_Jump_on_Cliff(float normalizedTime)
        {
          if (normalizedTime >= Cliff.minValue && normalizedTime <= Cliff.maxValue)
            {
                if (Physics.Raycast(animal.Main_Pivot_Point, -transform.up, out JumpRay, CliffRay * animal.ScaleFactor, animal.GroundLayer))
                {
                    if (Vector3.Angle(JumpRay.normal, Vector3.up) < animal.maxAngleSlope)       //Jump to a jumpable cliff not an inclined one
                    {
                        if (animal.debug)
                        {
                            Debug.DrawLine(animal.Main_Pivot_Point, JumpRay.point, Color.black);
                            MalbersTools.DebugTriangle(JumpRay.point, 0.1f, Color.black);
                        }
                        animal.SetIntID(110);
                    }
                }
                else
                {
                    if (animal.debug)
                    {
                        Debug.DrawRay(animal.Main_Pivot_Point, - transform.up * CliffRay * animal.ScaleFactor, Color.black);
                        MalbersTools.DebugPlane(animal.Main_Pivot_Point - ( transform.up * CliffRay * animal.ScaleFactor), 0.1f, Color.black);
                    }
                }
            }
        }

19 View Source File : RaycastToFace.cs
License : MIT License
Project Creator : IxxyXR

void Update()
    {
        Vector3 p0, p1, p2;
        Transform hitTransform;

        if (HighlightSelection)
        {
            foreach (var faceIndex in SelectedFaces)
            {
                foreach (var edge in polyBeforeOp.Faces[faceIndex].GetHalfedges())
                {
                    p0 = edge.Vertex.Position;
                    p1 = edge.Next.Vertex.Position;
                    hitTransform = gameObject.transform;
                    p0 = hitTransform.TransformPoint(p0);
                    p1 = hitTransform.TransformPoint(p1);
                    Debug.DrawLine(p0, p1);
                }
            }
        }
        
        RaycastHit hit;
        if (!Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
            return;
        MeshCollider meshCollider = hit.collider as MeshCollider;
        if (meshCollider == null || meshCollider.sharedMesh == null)
            return;

        hitTransform = hit.collider.transform;
        int hitFaceIndex = Mathf.FloorToInt(miscUVs2[hit.triangleIndex * 3][3]);
        
        foreach (var edge in polyBeforeOp.Faces[hitFaceIndex].GetHalfedges())
        {
            p0 = edge.Vertex.Position;
            p1 = edge.Next.Vertex.Position;
            hitTransform = hitTransform.transform;
            p0 = hitTransform.TransformPoint(p0);
            p1 = hitTransform.TransformPoint(p1);
            Debug.DrawLine(p0, p1, Color.cyan);
        }

        if (Input.GetMouseButtonDown(0))
        {
            if (SelectedFaces.Contains(hitFaceIndex))
            {
                SelectedFaces.Remove(hitFaceIndex);
            }
            else
            {
                SelectedFaces.Add(hitFaceIndex);
            }
            Generate();
        }

    }

19 View Source File : VisualizeMeshAttributes.cs
License : MIT License
Project Creator : KhronosGroup

void Update()
		{
			if (vertices != null)
			{
				int numVerts = vertices.Length;
				for (int vertexIndex = 0; vertexIndex < numVerts; vertexIndex++)
				{
					var vertexTransformed = this.transform.TransformPoint(vertices[vertexIndex]);

					if (VisualizeNormals && normals != null)
					{
						var normalTransformed = this.transform.InverseTransformVector(normals[vertexIndex]);
						Debug.DrawLine(vertexTransformed, vertexTransformed + normalTransformed * NormalScale * 0.5f,
							Color.green);
						Debug.DrawLine(vertexTransformed + normalTransformed * NormalScale * 0.5f,
							vertexTransformed + normalTransformed * NormalScale * 1.0f, Color.blue);
					}

					if (VisualizeTangents && tangents != null)
					{
						var tangentTransformed = this.transform.TransformVector(
							tangents[vertexIndex].w * new Vector3(tangents[vertexIndex].x, tangents[vertexIndex].y,
								tangents[vertexIndex].z));
						Debug.DrawLine(vertexTransformed, vertexTransformed + tangentTransformed * TangentScale * 0.5f,
							Color.black);
						Debug.DrawLine(vertexTransformed + tangentTransformed * TangentScale * 0.5f,
							vertexTransformed + tangentTransformed * TangentScale * 1.0f, Color.white);
					}
				}
			}
		}

19 View Source File : Debugging.cs
License : MIT License
Project Creator : LunariStudios

public static void DrawWireBox2D(Vector2 center, Vector2 size) {
            var halfWidth = size.x / 2;
            var halfHeight = size.y / 2;
            var bottomLeft = new Vector2(center.x - halfWidth, center.y - halfHeight);
            var topLeft = new Vector2(center.x - halfWidth, center.y + halfHeight);
            var bottomRight = new Vector2(center.x + halfWidth, center.y - halfHeight);
            var topRight = new Vector2(center.x + halfWidth, center.y + halfHeight);
            Debug.DrawLine(bottomLeft, topLeft);
            Debug.DrawLine(topLeft, topRight);
            Debug.DrawLine(topRight, bottomRight);
            Debug.DrawLine(bottomRight, bottomLeft);
        }

19 View Source File : DebugFinger.cs
License : Apache License 2.0
Project Creator : OOXXXXOO

protected void DrawDebugLines() {
    for (int i = 0; i < NUM_BONES; ++i)
      Debug.DrawLine(GetJointPosition(i), GetJointPosition(i + 1), colors[i]);
  }

19 View Source File : DebugHand.cs
License : Apache License 2.0
Project Creator : OOXXXXOO

protected void DrawDebugLines() {
    HandModel hand = GetComponent<HandModel>();
    Debug.DrawLine(hand.GetElbowPosition(), hand.GetWristPosition(), Color.red);
    Debug.DrawLine(hand.GetWristPosition(), hand.GetPalmPosition(), Color.white);
    Debug.DrawLine(hand.GetPalmPosition(),
                   hand.GetPalmPosition() + hand.GetPalmNormal(), Color.black);
    Debug.Log(Vector3.Dot(hand.GetPalmDirection(), hand.GetPalmNormal()));
  }

19 View Source File : Airplane_Realtime.cs
License : MIT License
Project Creator : SmallPlanet

public void UpdateInfo(FlightInfo info) {
        this.info = info;
        var alreplacedude = info.alreplacedude * meter * 100; //With the scale of the earth, you can't really see the difference in alreplacedude height between planes, so multiply by 100 to exaggerate it.
        Debug.DrawLine(transform.position, transform.position + -transform.up * alreplacedude, Color.yellow, 2f);

        transform.rotation = Quaternion.idenreplacedy;
        planeModel.rotation = Quaternion.idenreplacedy;

        //Heading is based on angle from north pole, so look at true north then rotate to heading
        planeModel.rotation = Quaternion.LookRotation(northPole.position - planeModel.position);
        planeModel.rotation = Quaternion.Euler(0f, info.heading + planeModel.rotation.eulerAngles.y, 0f);

        var line = PlanetUtility.VectorFromLatLng(info.location.lareplacedude, info.location.longitude, Vector3.right);
        var planetHit = PlanetUtility.LineFromOriginToSurface(planet, line, LayerMask.GetMask("Planet"));

        if (planetHit.HasValue) {
            Debug.DrawLine(planetHit.Value.point, planetHit.Value.point + planetHit.Value.point * alreplacedude, Color.red, 2f);

            transform.position = planetHit.Value.point + planetHit.Value.point * alreplacedude;
            transform.up = planetHit.Value.normal;
        }
    }

19 View Source File : RVOCoreSimulator.cs
License : MIT License
Project Creator : XINCGer

public void UpdateObstacle (ObstacleVertex obstacle, Vector3[] vertices, Matrix4x4 matrix) {
			if (vertices == null) throw new System.ArgumentNullException("Vertices must not be null");
			if (obstacle == null) throw new System.ArgumentNullException("Obstacle must not be null");

			if (vertices.Length < 2) throw new System.ArgumentException("Less than 2 vertices in an obstacle");

			bool idenreplacedy = matrix == Matrix4x4.idenreplacedy;

			// Don't interfere with ongoing calculations
			BlockUntilSimulationStepIsDone();

			int count = 0;

			// Obstacles are represented using linked lists
			var vertex = obstacle;
			do {
				if (count >= vertices.Length) {
					Debug.DrawLine(vertex.prev.position, vertex.position, Color.red);
					throw new System.ArgumentException("Obstacle has more vertices than supplied for updating (" + vertices.Length+ " supplied)");
				}

				// Premature optimization ftw!
				vertex.position = idenreplacedy ? vertices[count] : matrix.MultiplyPoint3x4(vertices[count]);
				vertex = vertex.next;
				count++;
			} while (vertex != obstacle && vertex != null);

			vertex = obstacle;
			do {
				if (vertex.next == null) {
					vertex.dir = Vector2.zero;
				} else {
					Vector3 dir = vertex.next.position - vertex.position;
					vertex.dir = new Vector2(dir.x, dir.z).normalized;
				}

				vertex = vertex.next;
			} while (vertex != obstacle && vertex != null);

			ScheduleCleanObstacles();
			UpdateObstacles();
		}

19 View Source File : RVOQuadtree.cs
License : MIT License
Project Creator : XINCGer

void DebugDrawRec (int i, Rect r) {
			Debug.DrawLine(new Vector3(r.xMin, 0, r.yMin), new Vector3(r.xMax, 0, r.yMin), Color.white);
			Debug.DrawLine(new Vector3(r.xMax, 0, r.yMin), new Vector3(r.xMax, 0, r.yMax), Color.white);
			Debug.DrawLine(new Vector3(r.xMax, 0, r.yMax), new Vector3(r.xMin, 0, r.yMax), Color.white);
			Debug.DrawLine(new Vector3(r.xMin, 0, r.yMax), new Vector3(r.xMin, 0, r.yMin), Color.white);

			if (nodes[i].child00 != i) {
				// Not a leaf node
				Vector2 c = r.center;
				DebugDrawRec(nodes[i].child11, Rect.MinMaxRect(c.x, c.y, r.xMax, r.yMax));
				DebugDrawRec(nodes[i].child10, Rect.MinMaxRect(c.x, r.yMin, r.xMax, c.y));
				DebugDrawRec(nodes[i].child01, Rect.MinMaxRect(r.xMin, c.y, c.x, r.yMax));
				DebugDrawRec(nodes[i].child00, Rect.MinMaxRect(r.xMin, r.yMin, c.x, c.y));
			}

			for (Agent a = nodes[i].linkedList; a != null; a = a.next) {
				var p = nodes[i].linkedList.position;
				Debug.DrawLine(new Vector3(p.x, 0, p.y)+Vector3.up, new Vector3(a.position.x, 0, a.position.y)+Vector3.up, new Color(1, 1, 0, 0.5f));
			}
		}

19 View Source File : AdvancedSmooth.cs
License : MIT License
Project Creator : XINCGer

public void DebugCircleSegment (Vector3 center, double startAngle, double endAngle, double radius, Color color) {
				double step = ThreeSixtyRadians / 100;

				while (endAngle < startAngle) {
					endAngle += ThreeSixtyRadians;
				}

				Vector3 prev = AngleToVector(startAngle)*(float)radius+center;
				for (double i = startAngle+step; i < endAngle; i += step) {
					Debug.DrawLine(prev, AngleToVector(i)*(float)radius+center);
				}

				Debug.DrawLine(prev, AngleToVector(endAngle)*(float)radius+center);
			}

19 View Source File : BBTree.cs
License : MIT License
Project Creator : XINCGer

[System.Diagnostics.Conditional("ASTARDEBUG")]
		static void DrawDebugNode (TriangleMeshNode node, float yoffset, Color color) {
			Debug.DrawLine((Vector3)node.GetVertex(1) + Vector3.up*yoffset, (Vector3)node.GetVertex(2) + Vector3.up*yoffset, color);
			Debug.DrawLine((Vector3)node.GetVertex(0) + Vector3.up*yoffset, (Vector3)node.GetVertex(1) + Vector3.up*yoffset, color);
			Debug.DrawLine((Vector3)node.GetVertex(2) + Vector3.up*yoffset, (Vector3)node.GetVertex(0) + Vector3.up*yoffset, color);
		}