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

hash 0 error(solved)

Discussion in 'Scripting' started by tawdry, Feb 4, 2015.

  1. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,356
    Hi
    So i thought i had a good plan. Create 1 int in mecanim parameter call it change. then assign it a value 1-4 for each state run=2,walk=1 etc. but of course it doesn't work.In the script I type animator.SetInteger(change,1) but it does not enter walk. ..animator.SetInteger(change,2) does not enter run am i using the wrong command (SetInteger) here?
     
  2. tango209

    tango209

    Joined:
    Feb 23, 2011
    Posts:
    379
    If you open the Mechanim window while running your game in the editor it will show state changes and the current variable values.
     
  3. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,356
    Its just stuck in the idle state change= 0 . I want to know how to change the change value via script and setinteger was how i thought it would work but it does nothing. Basically just want to assign a value to "change" so animator.setinteger(change,2) should mean change=2?
     
    Last edited: Feb 4, 2015
  4. tango209

    tango209

    Joined:
    Feb 23, 2011
    Posts:
    379
    Did you set the Condition to your integer parameter 'equals' 1?

    mechanim1.png
     
  5. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,356
    Hey mate solved it had to do the following line first
    change = Animator.StringToHash("change");
    now it works perfect thx for the assist.
     
    tango209 likes this.