- Home /
DrawLine Is not doing anything.
I just need to draw a line over a vector for debug purposes. This is what I have:
var ownPos : Vector3 = transform.position;
var gravObj = GameObject.FindGameObjectsWithTag ("Gravity");
for (all in gravObj){
var allPos : Vector3 = all.transform.position;
Debug.DrawLine(ownPos, allPos, Color.red);
}
No errors.
Is this being called from an Update method every frame, or is it a one-shot?
ownPos is in the Start() function. Its location doesn't change. Everything else is in Update().
Answer by HappyMoo · Jan 24, 2014 at 08:00 PM
Why do you do another Find with every object if you already have it in all? You can just do
allPos = all.transform.position;
and Debug.DrawLines are usually only visible in SceneView. Make sure you didn't turn off Gizmos
For some reason I had it set in my $$anonymous$$d that I needed to do a search and forgot that I already did. Gizmos are all enabled.
Answer by CoreyNW · Jan 24, 2014 at 10:27 PM
I found the issue. DrawLine isn't active in in the scene view unless the game is running. My scene view was merged with game view so that I had more viewing space. When I click to start the game, the scene view switches to game view making DrawLine useless. When the game stops, so does DrawLine.
Are you serious? I give you the answer that it's only visible in sceneview and you post your own answer stating the same and then accepting that? Fix this, please
That's assumed. Code usually doesn't run if the game doesn't run. If none of your code runs while the game is stopped, why should it run because you add DrawLines?
Your answer
Follow this Question
Related Questions
How can I track disassembly code back to a script? 0 Answers
DrawLine from enemy to player 1 Answer
FPS Measurement Issue 0 Answers
Why does Debug.DrawLine offset sometimes? 1 Answer
Which Gizmo is Debug.DrawLine? 1 Answer