Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Stealth?!...gotcha..

Discussion in 'General Discussion' started by ZJP, Mar 19, 2013.

  1. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Last edited: Mar 19, 2013
  2. ColossalDuck

    ColossalDuck

    Joined:
    Jun 6, 2009
    Posts:
    3,246
  3. Kinos141

    Kinos141

    Joined:
    Jun 22, 2011
    Posts:
    969
    'bout f-ing time...
     
  4. dtg108

    dtg108

    Joined:
    Oct 1, 2012
    Posts:
    1,165
    YES! I've been wanting to see some stealth scripts. Downloading now! "on Unity's Tutorial area, coming very very soon." Wonder how soon :D.
     
  5. Kinos141

    Kinos141

    Joined:
    Jun 22, 2011
    Posts:
    969
    I can teach you how to do a stealth game, it's pretty simple. It has two states, hidden and seen, then it gets complicated!!! lol
     
    Last edited: Mar 19, 2013
  6. The Ghost

    The Ghost

    Joined:
    Jul 7, 2012
    Posts:
    188
    Woot, excited.
     
  7. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
  8. BIG-BUG

    BIG-BUG

    Joined:
    Mar 29, 2009
    Posts:
    457
    Wohoo, thank you Unity for those great projects and assets!
     
  9. fano_linux

    fano_linux

    Joined:
    Jan 1, 2012
    Posts:
    909
  10. ColossalDuck

    ColossalDuck

    Joined:
    Jun 6, 2009
    Posts:
    3,246
    Woah, that's an in depth tutorial, I almost wish I was a noob again.
     
  11. giyomu

    giyomu

    Joined:
    Oct 6, 2008
    Posts:
    1,094
    well just pretend you are a noob ^^
     
  12. yls

    yls

    Joined:
    Apr 13, 2012
    Posts:
    195
    There is always a Noob inside...

    I was supposed to go to the gym, but now i have a tutorial to do :D
     
  13. Kinos141

    Kinos141

    Joined:
    Jun 22, 2011
    Posts:
    969
    HAHA.
     
  14. SkullKing

    SkullKing

    Joined:
    May 31, 2012
    Posts:
    40
    When trying to r8un the done scene I keep getting a lot(48 ) of the error message:

    "The class defined in script file named 'filename' does not match the file name!

    anyone else had this problem?
     
  15. munaeem

    munaeem

    Joined:
    Jul 6, 2012
    Posts:
    13
    yup i have it too, you solved it ?
     
  16. JamesB

    JamesB

    Unity Technologies

    Joined:
    Feb 21, 2012
    Posts:
    133
    @SkullKing and munaeem

    I have tried running a fresh download of the Stealth project's DoneStealth scene and I was unable to reproduce what you're finding. Have you edited the scripts at all? Remember that whilst in javascript you can change the script name without worrying (if you have an implicit class definition) but In C# the class definition is always explicit and so you can't change the class or script name so easily.

    If you have any repro steps for this bug please let me know and I'll look into
     
  17. landon912

    landon912

    Joined:
    Nov 8, 2011
    Posts:
    1,579
    Nice work mate, glad unity finally got some guys working on tutorials. Wish I had this a year ago. :)
     
  18. slideinsideways

    slideinsideways

    Joined:
    Mar 14, 2013
    Posts:
    1
  19. Topgunpl

    Topgunpl

    Joined:
    Jan 19, 2013
    Posts:
    3
  20. AdamCNorton

    AdamCNorton

    Joined:
    Apr 16, 2013
    Posts:
    57
    Well my problem is that I typed the scripts along with the videos. I got the following compile errors. So then I went and copy and pasted your code in the tutorial pages into the scripts instead, and I still get the following errors. I went line by line and verified everything is the same as yours. So I'm stuck since I'm not a coder.

    Assets/Scripts/LastPlayerSighting.cs(23,55): error CS0117: `Tags' does not contain a definition for `AlarmLight'
    Assets/Scripts/LastPlayerSighting.cs(23,28): error CS1502: The best overloaded method match for `UnityEngine.GameObject.FindGameObjectWithTag(string)' has some invalid arguments
    Assets/Scripts/LastPlayerSighting.cs(23,28): error CS1503: Argument `#1' cannot convert `object' expression to type `string'
     
  21. Kinos141

    Kinos141

    Joined:
    Jun 22, 2011
    Posts:
    969
    I had the same issue. The Hash tag script has different variable names than the script you using. You have to match the variables. I say go into the hash tag script and rename it to the errors names.

    I could help more if you post the code.
     
  22. AdamCNorton

    AdamCNorton

    Joined:
    Apr 16, 2013
    Posts:
    57
    Actually, yes, if you could that would be helpful. I'm pasting the code here. Unless I'm misunderstanding you, it looks to me like they are the same. Thanks for your help!

    using UnityEngine;
    using System.Collections;

    public class LastPlayerSighting : MonoBehaviour
    {
    public Vector3 position = new Vector3(1000f, 1000f, 1000f); // The last global sighting of the player.
    public Vector3 resetPosition = new Vector3(1000f, 1000f, 1000f); // The default position if the player is not in sight.
    public float lightHighIntensity = 0.25f; // The directional light's intensity when the alarms are off.
    public float lightLowIntensity = 0f; // The directional light's intensity when the alarms are on.
    public float fadeSpeed = 7f; // How fast the light fades between low and high intensity.
    public float musicFadeSpeed = 1f; // The speed at which the


    private AlarmLight alarm; // Reference to the AlarmLight script.
    private Light mainLight; // Reference to the main light.
    private AudioSource panicAudio; // Reference to the AudioSource of the panic msuic.
    private AudioSource[] sirens; // Reference to the AudioSources of the megaphones.


    void Awake ()
    {
    // Setup the reference to the alarm light.
    alarm = GameObject.FindGameObjectWithTag(Tags.alarmLight).GetComponent<alarmLight>();

    // Setup the reference to the main directional light in the scene.
    mainLight = GameObject.FindGameObjectWithTag(Tags.mainLight).light;

    // Setup the reference to the additonal audio source.
    panicAudio = transform.FindChild("secondaryMusic").audio;

    // Find an array of the siren gameobjects.
    GameObject[] sirenGameObjects = GameObject.FindGameObjectsWithTag(Tags.siren);

    // Set the sirens array to have the same number of elements as there are gameobjects.
    sirens = new AudioSource[sirenGameObjects.Length];

    // For all the sirens allocate the audio source of the gameobjects.
    for(int i = 0; i < sirens.Length; i++)
    {
    sirens = sirenGameObjects.audio;
    }
    }


    void Update ()
    {
    // Switch the alarms and fade the music.
    SwitchAlarms();
    MusicFading();
    }


    void SwitchAlarms ()
    {
    // Set the alarm light to be on or off.
    alarm.alarmOn = position != resetPosition;

    // Create a new intensity.
    float newIntensity;

    // If the position is not the reset position...
    if(position != resetPosition)
    // ... then set the new intensity to low.
    newIntensity = lightLowIntensity;
    else
    // Otherwise set the new intensity to high.
    newIntensity = lightHighIntensity;

    // Fade the directional light's intensity in or out.
    mainLight.intensity = Mathf.Lerp(mainLight.intensity, newIntensity, fadeSpeed * Time.deltaTime);

    // For all of the sirens...
    for(int i = 0; i < sirens.Length; i++)
    {
    // ... if alarm is triggered and the audio isn't playing, then play the audio.
    if(position != resetPosition !sirens.isPlaying)
    sirens.Play();
    // Otherwise if the alarm isn't triggered, stop the audio.
    else if(position == resetPosition)
    sirens.Stop();
    }
    }


    void MusicFading ()
    {
    // If the alarm is not being triggered...
    if(position != resetPosition)
    {
    // ... fade out the normal music...
    audio.volume = Mathf.Lerp(audio.volume, 0f, musicFadeSpeed * Time.deltaTime);

    // ... and fade in the panic music.
    panicAudio.volume = Mathf.Lerp(panicAudio.volume, 0.8f, musicFadeSpeed * Time.deltaTime);
    }
    else
    {
    // Otherwise fade in the normal music and fade out the panic music.
    audio.volume = Mathf.Lerp(audio.volume, 0.8f, musicFadeSpeed * Time.deltaTime);
    panicAudio.volume = Mathf.Lerp(panicAudio.volume, 0f, musicFadeSpeed * Time.deltaTime);
    }
    }
    }
     
  23. Kinos141

    Kinos141

    Joined:
    Jun 22, 2011
    Posts:
    969
    *Please use code wrap next time.*

    Also, At line 23, the error says Tag doesn't have a definition for alarmLight, that's because it wasn't added to the Tags script. You have to add this in the same way you added the rest.

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class LastPlayerSighting : MonoBehaviour
    6. {
    7. public Vector3 position = new Vector3(1000f, 1000f, 1000f); // The last global sighting of the player.
    8. public Vector3 resetPosition = new Vector3(1000f, 1000f, 1000f); // The default position if the player is not in sight.
    9. public float lightHighIntensity = 0.25f; // The directional light's intensity when the alarms are off.
    10. public float lightLowIntensity = 0f; // The directional light's intensity when the alarms are on.
    11. public float fadeSpeed = 7f; // How fast the light fades between low and high intensity.
    12. public float musicFadeSpeed = 1f; // The speed at which the
    13.  
    14.  
    15. private AlarmLight alarm; // Reference to the AlarmLight script.
    16. private Light mainLight; // Reference to the main light.
    17. private AudioSource panicAudio; // Reference to the AudioSource of the panic msuic.
    18. private AudioSource[] sirens; // Reference to the AudioSources of the megaphones.
    19.  
    20.  
    21. void Awake ()
    22. {
    23. // Setup the reference to the alarm light.
    24. alarm = GameObject.FindGameObjectWithTag(Tags.alarmLight). GetComponent<alarmLight>();
    25.  
    26. // Setup the reference to the main directional light in the scene.
    27. mainLight = GameObject.FindGameObjectWithTag(Tags.mainLight).l ight;
    28.  
    29. // Setup the reference to the additonal audio source.
    30. panicAudio = transform.FindChild("secondaryMusic").audio;
    31.  
    32. // Find an array of the siren gameobjects.
    33. GameObject[] sirenGameObjects = GameObject.FindGameObjectsWithTag(Tags.siren);
    34.  
    35. // Set the sirens array to have the same number of elements as there are gameobjects.
    36. sirens = new AudioSource[sirenGameObjects.Length];
    37.  
    38. // For all the sirens allocate the audio source of the gameobjects.
    39. for(int i = 0; i < sirens.Length; i++)
    40. {
    41. sirens[i] = sirenGameObjects[i].audio;
    42. }
    43. }
    44.  
    45.  
    46. void Update ()
    47. {
    48. // Switch the alarms and fade the music.
    49. SwitchAlarms();
    50. MusicFading();
    51. }
    52.  
    53.  
    54. void SwitchAlarms ()
    55. {
    56. // Set the alarm light to be on or off.
    57. alarm.alarmOn = position != resetPosition;
    58.  
    59. // Create a new intensity.
    60. float newIntensity;
    61.  
    62. // If the position is not the reset position...
    63. if(position != resetPosition)
    64. // ... then set the new intensity to low.
    65. newIntensity = lightLowIntensity;
    66. else
    67. // Otherwise set the new intensity to high.
    68. newIntensity = lightHighIntensity;
    69.  
    70. // Fade the directional light's intensity in or out.
    71. mainLight.intensity = Mathf.Lerp(mainLight.intensity, newIntensity, fadeSpeed * Time.deltaTime);
    72.  
    73. // For all of the sirens...
    74. for(int i = 0; i < sirens.Length; i++)
    75. {
    76. // ... if alarm is triggered and the audio isn't playing, then play the audio.
    77. if(position != resetPosition  !sirens[i].isPlaying)
    78. sirens[i].Play();
    79. // Otherwise if the alarm isn't triggered, stop the audio.
    80. else if(position == resetPosition)
    81. sirens[i].Stop();
    82. }
    83. }
    84.  
    85.  
    86. void MusicFading ()
    87. {
    88. // If the alarm is not being triggered...
    89. if(position != resetPosition)
    90. {
    91. // ... fade out the normal music...
    92. audio.volume = Mathf.Lerp(audio.volume, 0f, musicFadeSpeed * Time.deltaTime);
    93.  
    94. // ... and fade in the panic music.
    95. panicAudio.volume = Mathf.Lerp(panicAudio.volume, 0.8f, musicFadeSpeed * Time.deltaTime);
    96. }
    97. else
    98. {
    99. // Otherwise fade in the normal music and fade out the panic music.
    100. audio.volume = Mathf.Lerp(audio.volume, 0.8f, musicFadeSpeed * Time.deltaTime);
    101. panicAudio.volume = Mathf.Lerp(panicAudio.volume, 0f, musicFadeSpeed * Time.deltaTime);
    102. }
    103. }
    104. }
    105.  
     
  24. AdamCNorton

    AdamCNorton

    Joined:
    Apr 16, 2013
    Posts:
    57
    Thanks, I am confused though. Here is my Tags script. Is line #7(the alarm line) not the line you're saying is missing? Or does their need to be an additional variable for Alarm Light? It's confusing to me. It is obvious to me that it's missing like you say. But it's not obvious to me what it should be. Sorry, told you I'm a noob coder. Maybe not even up to noob quite yet!


    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Tags : MonoBehaviour
    5. {
    6.     public const string player = "Player";
    7.     public const string alarm = "AlarmLight";
    8.     public const string siren = "Siren";
    9.     public const string gameController = "GameController";
    10.     public const string mainLight = "MainLight";
    11.     public const string fader = "Fader";
    12.     public const string enemy = "Enemy";
    13.  
    14. }
     
  25. Kinos141

    Kinos141

    Joined:
    Jun 22, 2011
    Posts:
    969
    Yes, LastPlayerSighting class says it's missing the variable: alarmLight, in Tags, your variable is alarm. Remember, different names, computer complains. So one has to change to match the other.
     
  26. valleyDweller

    valleyDweller

    Joined:
    May 9, 2013
    Posts:
    1
    I'm having the same issue with this. I had to fix a typo in another script as well, as it deviated from the on-screen text.
    I'm still stuck on getting the alarm music to switch. The lights change though, so that's good. I'm about to just skip to the next step.
     
  27. JamesB

    JamesB

    Unity Technologies

    Joined:
    Feb 21, 2012
    Posts:
    133
    Hey guys. I think the problem is just caused by an old script being shown beneath the Tags Management assignment. The correct script should now be shown. This should solve the tag problems you're having.
    When the game was being made we went through a number of iterations and one of the previous ones needed more tags to do with alarms, thus the mismatch.
     
  28. MarigoldFleur

    MarigoldFleur

    Joined:
    May 12, 2012
    Posts:
    1,353
    You should keep using the wrong scripts so people won't just rigidly follow the tutorials and instead need to actually learn how their code works.
     
  29. MikeTea

    MikeTea

    Joined:
    Jun 5, 2013
    Posts:
    4
    OK, I give up. How do I download the assets? The only link I see on the asset store page is Open in Unity, which brings up my empty, virginal Unity Project Wizard dialog, with nary a Stealth in sight. I know this sounds like a ridiculous question, but would someone please tell me exactly what I'm supposed to do?
     
  30. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Open in Unity should open the Asset Store... if not open it manually from the window menu (maybe you don't have the latest version??). Browse to this project from there. Click Download.
     
  31. MikeTea

    MikeTea

    Joined:
    Jun 5, 2013
    Posts:
    4
    Thanks for the reply. I just figured it out. I needed to select create a new project from the wizard. Only after I do that does Unity actually open and (re)open the asset store from within the app. From a UI standpoint, you'd think (well, I thought) that launching the app with a "...and automatically download this from the Asset Store" switch would cause the app to bypass the wizard, or at least show a prompt that indicates that a download is pending. So much to learn...
     
  32. The_Other_Guy

    The_Other_Guy

    Joined:
    Jul 14, 2013
    Posts:
    1
    I understand. But do you think it is fair to let someone completely out in the cold just because they dont know the language? I am actually trying to figure this out, but I have no idea where to start. It would be nice to get through the tutorial just to have an understanding of what Unity3D is, but right now I have the understanding that there is no help to get even when you only need a hint.
     
  33. timkav02

    timkav02

    Joined:
    Jun 4, 2013
    Posts:
    1
    Can anyone get me a link with compressed file of the stealth game assets they downloaded i have tried downloading it lyk 4 times and it stops around 97%. I'm tired of having to pay for data and not getting what I paid for....I have unity Pro4.1.5 and would really lyk to get started with the tutorials.. Please anyone..
     
  34. ARluka

    ARluka

    Joined:
    Mar 28, 2013
    Posts:
    1
    The solution is this:
    All that I did is capitalised the AlarmLight and added the Done word next to Tags and here it is...

    using UnityEngine;
    using System.Collections;

    public class LastPlayerSighting : MonoBehaviour
    {
    public Vector3 position = new Vector3(1000f, 1000f, 1000f);
    public Vector3 resetPosition = new Vector3(1000f, 1000f, 1000f);
    public float lightHighIntensity = 0.25f;
    public float lightLowIntensity = 0f;
    public float fadeSpeed = 7f;
    public float musicFadeSpeed = 1f;

    private AlarmLight alarm;
    private Light mainLight;
    private AudioSource panicAudio;
    private AudioSource[] sirens;

    void Awake()
    {
    alarm = GameObject.FindGameObjectWithTag(DoneTags.alarm).GetComponent<AlarmLight>();
    mainLight = GameObject.FindGameObjectWithTag(DoneTags.mainLight).light;
    panicAudio = transform.Find("secondaryMusic").audio;
    GameObject[] sirenGameObjects = GameObject.FindGameObjectsWithTag(DoneTags.siren);
    sirens = new AudioSource[sirenGameObjects.Length];

    for(int i = 0; i < sirens.Length; i++)
    {
    sirens = sirenGameObjects.audio;
    }
    }

    void Update ()
    {
    SwitchAlarms();
    MusicFading();
    }

    void SwitchAlarms()
    {
    alarm.alarmOn = position != resetPosition;

    float newIntensity;

    if(position != resetPosition)
    {
    newIntensity = lightLowIntensity;
    }
    else
    {
    newIntensity = lightHighIntensity;
    }

    mainLight.intensity = Mathf.Lerp (mainLight.intensity, newIntensity, fadeSpeed * Time.deltaTime);

    for(int i = 0; i < sirens.Length; i++)
    {
    if(position != resetPosition !sirens.isPlaying)
    {
    sirens.Play();
    }
    else if(position == resetPosition)
    {
    sirens.Stop ();
    }
    }
    }

    void MusicFading()
    {
    if(position != resetPosition)
    {
    audio.volume = Mathf.Lerp (audio.volume, 0f, musicFadeSpeed * Time.deltaTime);
    panicAudio.volume = Mathf.Lerp (panicAudio.volume, 0.8f, musicFadeSpeed * Time.deltaTime);
    }
    else
    {
    audio.volume = Mathf.Lerp (audio.volume, 0.8f, musicFadeSpeed * Time.deltaTime);
    panicAudio.volume = Mathf.Lerp (panicAudio.volume, 0f, musicFadeSpeed * Time.deltaTime);
    }
    }
    }
     
  35. kanga

    kanga

    Joined:
    Mar 22, 2010
    Posts:
    225
    I copied and pasted this code in a fresh notepad++ doc. Saved it out as C# and it returns an error in the console cs(13,9): error cs0246 The type or namespace name 'AlarmLight' could not be found. Are you missing a using directive or an assembly reference?

    Almost exactly the same error I had when copying the text from the vid. Stared at it till my glasses fogged and still coulnt find the fault. Deleting the above and dragging the DoneLastPlayerSighting script from the project Done folder works fine in case anyone else is looking.

    Stealth is the best tute yet.
    Edit: Ug, now I am getting a NullReferenceException The script actually crashes unity. There should not be a null reference because the secondaryMusic object exists in my scene and has a sound clip attached. Hmm

    The script I copied didnt work, the one under the video didn't work, this one here didn't and the one the project comes with doesnt work. I am definitely suffering voodoo :)
     
    Last edited: Sep 28, 2013
  36. kanga

    kanga

    Joined:
    Mar 22, 2010
    Posts:
    225
    Oh dear I know what it is. I am following the tutorial with my own project. Had to be that my scene is missing items referenced by the script. Doh. My apologies its not Unity or the code just the nut on this end.
     
  37. bharris

    bharris

    Joined:
    Oct 17, 2013
    Posts:
    1
    Kanga,

    Was this the error you were getting?

    NullReferenceException
    UnityEngine.GameObject.GetComponent[AlarmLight] () (at C:/BuildAgent/work/ea95e74f6e5f192d/Runtime/ExportGenerated/Editor/UnityEngineGameObject.cs:27)
    LastPlayerSighting.Awake () (at Assets/Scripts/LastPlayerSighting.cs:23)

    If so, how did you resolve this? I clearly have this in my project, and have checked and double checked for syntax errors, I just cant seem to see what the problem is.
     
  38. kanga

    kanga

    Joined:
    Mar 22, 2010
    Posts:
    225
    Hey bharris!
    Yo, I was copying scripts and implementing them without having all the elements in my scene, hence the NullReference. Either you are missing the elements a script is referring to or you have spelling mistakes on the actual items that the script is referencing.

    I swear I am going to learn to code, even if it is just to stop asking the questions I most often ask :)
     
  39. JamesB

    JamesB

    Unity Technologies

    Joined:
    Feb 21, 2012
    Posts:
    133
    Hey guys, it looks like Unity isn't finding your AlarmLight script. My first guess would be that it's called DoneAlarmLight instead. Unfortunately without a detailed look at your project it's difficult to know what it could be. Check over some of the following things:
    - We had some trouble a while ago with extra tags that weren't supposed to be in the finished project but managed to sneak through. The tag you should be using for both the Tags script and applied to the alarm directional light is "AlarmLight" not "Alarm".
    - Make sure that an AlarmLight script is attached to your directional alarm light gameobject.
    - Make sure the directional alarm light is tagged AlarmLight
    - If you're still having trouble break up the line from LastPlayerSighting to the following:

    GameObject alarmGO = GameObject.FindGameObjectWithTag(Tags.alarm);
    alarm = alarmGO.GetComponent<AlarmLight>();

    After the replacing the code with the above (check for mistakes I've not compiled or checked it) you will be able to see if the null reference really refers to the gameobject it can't find or the script it can't find.

    I'm sorry I couldn't be of more help. Post back here with more details if you're still having trouble and I'll see if I can help some more.

    Good luck all!
     
  40. Jetsetneo

    Jetsetneo

    Joined:
    Jul 22, 2013
    Posts:
    1
    Hey guys I keep having the following issue pop up:

    Parameter 'Hash 621101035' does not exist.
    UnityEngine.Animator:SetBool(Int32, Boolean)
    EnemySight:Update() (at Assets/Scripts/Enemy/EnemySight.cs:52)

    Theoretically I finished the entire tutorial but this thing pops up, furthermore I'm certain its whats causing my guards not to shoot at all. All my scripts are from the tutorials, and I've double checked the HASHIds, but it doesn't seem to stick. The Enemy Sight code is straight off the website.
     
  41. mstj

    mstj

    Joined:
    Sep 15, 2013
    Posts:
    1
    Sorry for necroposting, but I though I would share a specific scenario I experienced and this thread was helpful for me to resolve it.

    The debugging technique of JamesB is the sure way to pinpoint the exact problem.
    Isolate Tags.alarm to a string ? Check! It returns "alarm".
    Isolate the GameObject with FindGameObjectWithTag() to the previous string? Check! It returns a valid GO.
    Isolate the return value of this GO with GetComponent<AlarmLight>(), it returns null.

    Simply put, the AlarmLight script isn't present anywhere. It's in the Scripts folder, but it's not attached to the actual game component. I checked my light_alarm_directional object, and lo and behold: No script. Added the script and voilà: it works.

    Now, the kicker is Why ? Why is light_alarm_directional suddenly empty ? Didn't I follow the tutorial so far to a dot ? Well, yes and no ... At one point, the tutorial tells us to tidy up the scripts. And I start moving the scripts at the top of the assets tree to the Scripts folder and think I did a good job. But I'm using SVN and I started committing stuff early on and after each tutorial. Moving scripts around in Unity isn't a good idea, as the assets hierarchy is the same as the file directory. If you don't track them in SVN before each commit, chances are that SVN will report missing files, and end up reverting them and then you svn move those missing files and some links between script and objects in Unity broke ... and magically disappear.

    There are probably less painful ways to use version control with Unity and I'm reading about it at the moment, but that problem gave me a hard time. So be careful when moving scripts around.

    Cheers.
     
  42. hadiw3i

    hadiw3i

    Joined:
    Jun 18, 2014
    Posts:
    3
    Parameter 'Hash -1089183267' does not exist.
    UnityEngine.Animator:SetFloat(Int32, Single, Single, Single)
    AnimatorSetup:Setup(Single, Single) (at Assets/Done/DoneScripts/UnappliedScripts/AnimatorSetup.cs:30)
    EnemyAnimation:NavAnimSetup() (at Assets/EnemyAnimation.cs:91)
    EnemyAnimation:Update() (at Assets/EnemyAnimation.cs:44)
    can u solve this?
    Regards,
    :D
     
  43. hadiw3i

    hadiw3i

    Joined:
    Jun 18, 2014
    Posts:
    3
    can u solve this?
    Parameter 'Hash -1089183267' does not exist.
    UnityEngine.Animator:SetFloat(Int32, Single, Single, Single)
    AnimatorSetup:Setup(Single, Single) (at Assets/Done/DoneScripts/UnappliedScripts/AnimatorSetup.cs:30)
    EnemyAnimation:NavAnimSetup() (at Assets/EnemyAnimation.cs:91)
    EnemyAnimation:Update() (at Assets/EnemyAnimation.cs:44)

    Regards
    :D
     
  44. hadiw3i

    hadiw3i

    Joined:
    Jun 18, 2014
    Posts:
    3
    anybody? would u mind to help me to solve that?
    T_T:(
     
  45. kudakitsune

    kudakitsune

    Joined:
    Jul 3, 2014
    Posts:
    1
    I dont know if you still had the problem. I made the tutorial recently and had the next error:
    -------------------
    Parameter 'Hash 621101035' does not exist.
    UnityEngine.Animator:SetBool(Int32, Boolean)
    EnemySight:Update() (at Assets/Scripts/Enemy/EnemySight.cs:41)
    --------------------------------
    That error appear to me with the boolean variable PlayerInSight, so i looked to EVERY reference to playerInSight in the diferents scripts where it appear and make sure that everything was exactly the same, because in some appeared has "PlayerInSight" and in other "playerInSight" (the first letter in uppercase or not). Once done that, checked the animator of the robotGuard and make sure that the boolean variable had the same name also. That fixed it for me. Hopes it helps you
     
  46. spinlud

    spinlud

    Joined:
    Aug 18, 2014
    Posts:
    14
    Hi guys!
    I am following this amazing tutorial, but i am stuck at the Player Movement lesson. I've copied exactly the scrips of the tutorial but in play mode i got a (neverending) list of these warnings in the console:


    Parameter 'Hash 450948767' does not exist.
    UnityEngine.Animator:SetBool(Int32, Boolean)
    PlayerMovement:MovementManagement(Single, Single, Boolean) (at Assets/Scripts/Player/PlayerMovement.cs:55)
    PlayerMovement:FixedUpdate() (at Assets/Scripts/Player/PlayerMovement.cs:36)

    Parameter 'Hash -823668238' does not exist.
    UnityEngine.Animator:SetFloat(Int32, Single)
    PlayerMovement:MovementManagement(Single, Single, Boolean) (at Assets/Scripts/Player/PlayerMovement.cs:66)
    PlayerMovement:FixedUpdate() (at Assets/Scripts/Player/PlayerMovement.cs:36)

    etc..


    I guess the problem is related to the StringToHash or the use of Tags, but i don't know how to solve it, since i've copied exactly the scripts of the tutorial. Any help?

    thanks in advance!
     
  47. JamesB

    JamesB

    Unity Technologies

    Joined:
    Feb 21, 2012
    Posts:
    133
    Hey spinlud,

    The errors you are seeing refer to the animator parameters. The editor cannot see any parameters on the player's animator controller that match the ones given to it in the PlayerMovement script. This is could be one of two things: the parameters created in the AnimatorController are not correct or the strings assigned in the HashIDs script are not correct.

    Unity uses strings to match the two thus if the animator parameter is called "speed" and the script has "Speed" in, it won't work. They need to match exactly. In this project we try to mitigate that chance of error slightly by using hash integers.

    Every animator parameter has a unique hash code for it's string, this is a number that uniquely represents that parameter based on it's string. In the HashIDs script we replicate all these hash identifiers so that we can pass in a variable when setting the parameters instead of a string. However, when the hash code is replicated in the script, it still needs to match the animator parameter's code and this can only be ensured by having the same string when using the Animator.StringToHash function.

    TL;DR - Make sure the animator parameters in your player's animator controller EXACTLY match the ones in the HashIDs script.
     
    Deshain likes this.
  48. CrazyZombieKiller

    CrazyZombieKiller

    Joined:
    Jun 8, 2015
    Posts:
    6
    Hi,

    I just solved similar problems in my tutorial.

    playerInSight:

    I had the EnemySight script attached to one of the robo guards, but not the other two. When I made the prefab EnemySight was not included. So I duplicated it without the script. I put it into one robo guard. So it looked okay, and I was stuck for weeks. I spend weeks (sporatically) watching tutorials, and running the debugger with checkpoints in Mono. It only told me that the enemySight script was inactive, returning a null. But I noticed when I clicked on the error it backfilled the game object for robo guard 2 with hello! That was were the error was coming from, not the guard I fixed. I forgot to fix the other two. So I copied the EnemySight script to the other two robo guards and problem solved!! The yellow back fill saved the day.

    hashid

    The same thing happend in reverse for the player. I had the enemySight script attached to it. Obviously, it couldn't find the animator objects for the enemy, hahah. So I removed the enemySight script off of player and hash error fixed. I discovered this by noticing that the player game object in the object hierarchy turned yellow when I clicked on the error. This is a very powerful tool in debugging.
     
  49. jeevanch

    jeevanch

    Joined:
    Sep 6, 2015
    Posts:
    1
    Please Help me with this what and where is the problem coz I only want to move the enemy.

    Parameter 'Hash -1089183267' does not exist.
    UnityEngine.Animator:SetFloat(Int32, Single, Single, Single)
    AnimatorSetup:Setup(Single, Single) (at Assets/Scripts/Unapplied/AnimatorSetup.cs:24)
    EnemyAnimation:NavAnimSetup() (at Assets/EnemyAnimation.cs:63)
    EnemyAnimation:Update() (at Assets/EnemyAnimation.cs:34)