Search Unity

localScale returns 1 even though inspector states 0.1, 0.2, 0.4

Discussion in 'Scripting' started by giantkilleroverunity3d, Oct 23, 2021.

  1. giantkilleroverunity3d

    giantkilleroverunity3d

    Joined:
    Feb 28, 2014
    Posts:
    383
    Hello,
    I instantiated 3 gameobjects of differing x scales i.e. 0.1, 0.2, 0,4.
    When I read transform.localScale.x of those gameobjects I get 1 in all instances.
    I scroll through the hierarchy to each GO and the inspector shows each its own scale
    But Debug.Log show 1 and game logic works as if the scales are all 1s.
    I dont know what to do.
    Thank you.
     
    Last edited: Oct 23, 2021
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,697
    Print the
    .name
    of the Transform you're getting the localRotation out of. I bet it's something else.
     
  3. giantkilleroverunity3d

    giantkilleroverunity3d

    Joined:
    Feb 28, 2014
    Posts:
    383
    Thank you sir. It was. Too much logic in the way.
    Had to post to get a distraction. Went back to code and saw the mess.
     
    Bunny83 and Kurt-Dekker like this.
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,697
    Debug.Log() is always my best friend. :)

    And for all the folks saying "JUST ATTACH THE DEBUGGER," I say

    "You attach the debugger and watch your game FREEZE on a breakpoint. I'll keep playing my game and have a big log of all the values."

    Oldskool FTW.
     
    adamgolden likes this.