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

Sprint script with stamina and sound help....

Discussion in 'Scripting' started by cyberianhd, Aug 29, 2012.

  1. cyberianhd

    cyberianhd

    Joined:
    Aug 20, 2012
    Posts:
    51
    I have a script that i need somebody to take a look at and tell me why it dosnt work and how to fix it. I got this from a freind a week ago, here it is:

    Code (csharp):
    1. ...
    2.  
    If you test the code it WILL NOT WORK FOR YOU, thats because it requires another script, but thats not important.
    When i use this script i get a error:

    Please help me fix it, thanks!
     
    Last edited: Aug 29, 2012
  2. wolfhunter777

    wolfhunter777

    Joined:
    Nov 3, 2011
    Posts:
    534
  3. cyberianhd

    cyberianhd

    Joined:
    Aug 20, 2012
    Posts:
    51
    Yes, i understand this, but where in the code will the fix be put in place?
     
  4. wolfhunter777

    wolfhunter777

    Joined:
    Nov 3, 2011
    Posts:
    534
    Set the AudioSource.clip to the breathingSound and call audio.Play().
     
  5. cyberianhd

    cyberianhd

    Joined:
    Aug 20, 2012
    Posts:
    51
    can you give a detailed explanation on how to do this? im sort of a noob...
     
  6. wolfhunter777

    wolfhunter777

    Joined:
    Nov 3, 2011
    Posts:
    534
    You need to give a audio clip to the audio so that it will have something to play. Just pass the audioclip into the clip of your audio and call Play() once that is passed in.
    Code (csharp):
    1.  
    2. audio.clip = breathingSound;
    3. audio.Play();
    4.  
     
  7. cyberianhd

    cyberianhd

    Joined:
    Aug 20, 2012
    Posts:
    51
    Ok, that fixed it, but when i go to run the game i get a error at line 51, do you know why this is?
     
  8. wolfhunter777

    wolfhunter777

    Joined:
    Nov 3, 2011
    Posts:
    534
    At Line51, I see this line:
    Code (csharp):
    1.  
    2. walksoundchange.waitTime = 0.6;
    3.  
    And you expect me to know what's wrong? Show me the code containing that class so I know what waitTime is suppose to be. Also, give me the error details, copy it, don't take a screenshot.
     
  9. cyberianhd

    cyberianhd

    Joined:
    Aug 20, 2012
    Posts:
    51
    Im sorry, im a noob, here is the code for the class:



    Here is my error:

    MissingFieldException: Field 'walksound.waitTime' not found.
    Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.FindExtension (IEnumerable`1 candidates)
    Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.Create (SetOrGet gos)
    Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.CreateSetter ()
    Boo.Lang.Runtime.RuntimeServices.DoCreatePropSetDispatcher (System.Object target, System.Type type, System.String name, System.Object value)
    Boo.Lang.Runtime.RuntimeServices.CreatePropSetDispatcher (System.Object target, System.String name, System.Object value)
    Boo.Lang.Runtime.RuntimeServices+<SetProperty>c__AnonStorey16.<>m__C ()
    Boo.Lang.Runtime.DynamicDispatching.DispatcherCache.Get (Boo.Lang.Runtime.DynamicDispatching.DispatcherKey key, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
    Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
    Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object[] args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
    Boo.Lang.Runtime.RuntimeServices.SetProperty (System.Object target, System.String name, System.Object value)
    staminasprint.Update () (at Assets/staminasprint.js:55)
     
    Last edited: Aug 29, 2012
  10. wolfhunter777

    wolfhunter777

    Joined:
    Nov 3, 2011
    Posts:
    534
    You never created the variable waitTime in your class walksound.
     
  11. cyberianhd

    cyberianhd

    Joined:
    Aug 20, 2012
    Posts:
    51
    can i delete the waittime or something and just get rid of it to get rid of the error?
     
    Last edited: Aug 29, 2012