#Trying to use Debug.DrawLine need help
1 messages · Page 1 of 1 (latest)
when i do using System.Diagnostics.Debug then
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Diagnostics.Debug;
using UnityEngine;
//using UnityEngine.Debug;
public class Points : MonoBehaviour
{
[System.Serializable]
public struct Point2D
{
public Point2D (float x, float y) { this.x = x; this.y = y; }
public float x;
public float y;
}
[System.Serializable]
public struct Vector2D
{
public Vector2D(float x, float y) { this.x = x; this.y = y; }
public float x;
public float y;
}
[System.Serializable]
public struct Vector3D
{
public Vector3D(float x, float y, float z) { this.x = x; this.y = y; this.z = z; }
public Vector3D(Vector2D v2) { this.x = v2.x; this.y = v2.y; this.z = 0; }
public float x;
public float y;
public float z;
}
[System.Serializable]
public struct Matrix2D
{
public Matrix2D(Vector2D xAxis, Vector2D yAxis, Vector2D tAxis)
{
this.xAxis = new Vector3D(xAxis);
this.yAxis = new Vector3D(yAxis);
this.tAxis = new Vector3D(tAxis);
}
// matrix multiplication photo note Mat102 folder
public Vector3D multiply(Vector3D vector)
{
float x = xAxis.x * vector.x + yAxis.x * vector.y + tAxis.x * vector.z;
float y = xAxis.y * vector.x + yAxis.y * vector.y + tAxis.y * vector.z;
float z = xAxis.z * vector.x + yAxis.z * vector.y + tAxis.z * vector.z;
return new Vector3D(x, y, z);
}
public Vector3D xAxis;
public Vector3D yAxis;
public Vector3D tAxis; // z
}
public GameObject pointRendererPrefab;
//[SerializeField]
public List<Point2D> points = new List<Point2D>();
//[SerializeField]
public List<Matrix2D> pointTransformations = new List<Matrix2D>();
//[SerializeField]
List<GameObject> pointsRenderers = new List<GameObject>();
private void Start()
{
for (int i = 0; i < points.Count; i++)
{
pointsRenderers.Add(GameObject.Instantiate(pointRendererPrefab));
}
}
private void Update()
{
for (int i = 0; i < points.Count; i++)
{
Point2D point = points[i];
GameObject pointRenderer = pointsRenderers[i];
Matrix2D pointTransformation = pointTransformations[i];
Vector3D pointInVector = new Vector3D(point.x, point.y, 1 );
Vector3D pointTransformed = pointTransformation.multiply( pointInVector );
Vector3D xAxis = new Vector3D(pointTransformation.xAxis.x, pointTransformation.xAxis.y, pointTransformation.xAxis.z);
Vector3D yAxis = new Vector3D(pointTransformation.yAxis.x, pointTransformation.yAxis.y, pointTransformation.yAxis.z);
Debug.DrawLine(Vector3D.zero, xAxis, Color.red);
Debug.DrawLine(Vector3D.zero, yAxis, Color.green);
// Do matrix multiplication to transfer my points into it's transformed space.
pointRenderer.transform.position = new Vector3(pointTransformed.x, pointTransformed.y, 0f);
}
}
}
thats the code
i am trying to do Debug.DrawLine like htis
it was what the system suggested also yeah it was Vector3
i am trying to recreate what my teacher does here
i replaced it with vector 3 but hese lines still
Debug.DrawLine(Vector3.zero, xAxis, Color.red);
Debug.DrawLine(Vector3.zero, yAxis, Color.green);
you were right !
system.diagnostics was interfering
i commented it out and now it shows
whice one said that ?
ah damn it was the original one yeah
Okay now i know this too
so when i am using for example
Using Unity
it also includes those stuff like debug
anyway ?
i assume if i wanted only a specific part i would have to do
using UnityEngine.Debug
okay i remember it was the same with using the math libraries
Thank you so much this took me 40 minutes trying to undrestand, i need to read errors more carefully
thank you !
btw another newbee thing sometimes this happens withoum me clicking anything
how can i have it on normal