Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Debug.Log Not Working?

Discussion in 'Scripting' started by Cooper37, Jun 27, 2014.

  1. Cooper37

    Cooper37

    Joined:
    Jul 21, 2012
    Posts:
    383
    I checked that Collapse and Clear on Play are not checked, and that the console can only display messages and errors(not warnings). When it didn't appear on the console at the bottom of Unity, I figured it may have been my script:

    Code (csharp):
    1.  
    2. function Update(){
    3.      if(controller.isGrounded){
    4.           Idle();
    5.      }
    6. }
    7.  
    8. function Idle                    () {
    9.     if(controller.velocity.sqrMagnitude >= 0.0){                                                    //Speed intervals for basic animation changes...
    10.         if(controller.velocity.sqrMagnitude <= minWalkVelocity){
    11.             print("Idel...");                                                                    //If the player is still or approaching the walk speed, idle
    12.         }
    13.     }
    14. }  
    15.  
    Any help on why this is happening will be nice. Thanks! :)
     
  2. Sharp-Development

    Sharp-Development

    Joined:
    Nov 14, 2013
    Posts:
    353
    Is it intention you use print instead of Debug.Log?
    Furthermore, if Debug.Log doesnt output anything to the console than your conditions are never met.
     
  3. Cooper37

    Cooper37

    Joined:
    Jul 21, 2012
    Posts:
    383
    My mistake, I was using Debug and tried print and it didn't work either. Are you sure it's not because the Update is calling a function?
     
  4. Sharp-Development

    Sharp-Development

    Joined:
    Nov 14, 2013
    Posts:
    353
    As of update calling a method, no worries, theres no problem in it.

    However, you have 3 conditions (which I quoted above) which need to be met (so true) in order for the Debug.Log to execute. So one of those conditions returns obviously false, check which one.
     
  5. Cooper37

    Cooper37

    Joined:
    Jul 21, 2012
    Posts:
    383
    I was working with a custom character controller and it needed gravity to work! :p I guess I fixed it. Thanks anyway Sharp! :)