Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by kingofstreets · Oct 01, 2014 at 12:33 AM · errorgamefootsteps

error with footsteps script

sorry if its something stupid i'm new to this xD

ERRORS:: Assets/models/playerfootstepD.js(15,1): BCE0077: It is not possible to invoke an expression of type 'UnityEngine.AudioClip'.

Assets/models/playerfootstepD.js(49,17): BCE0077: It is not possible to invoke an expression of type 'UnityEngine.AudioClip'.

Assets/models/playerfootstepD.js(69,17): BCE0077: It is not possible to invoke an expression of type 'UnityEngine.AudioClip'.

======================================================= #pragma strict

 var walksound : AudioClip;
 
 var isWalking : boolean = false;
 var isRunning : boolean = false;
 
 var walkcool : float = 0.6;
 var walkTimer : float = 0;
  
  
 function Update()
 {
 GetState();
 walksound();
 }
  
  
 function GetState()
 {
     if ( Input.GetAxis( "Horizontal" ) || Input.GetAxis( "Vertical" ) )
 {
     if ( Input.GetKey( "left shift" ) || Input.GetKey( "right shift" ) )
 {
     // Running
     isWalking = false;
     isRunning = true;
     }
 else
     {
     // Walking
     isWalking = true;
     isRunning = false;
     }
     }
 else
     {
     // Stopped
     isWalking = false;
     isRunning = false;
     }
 }
 
 function start()
 {
 if(isWalking == true)
     {
         walkcool = 0.6;
         walksound();
     }
 
 else
     {
     walkcool = 0.6;
     }
     if(walkTimer > 0)
     {
         walkTimer -= Time.deltaTime;
     }
 
     if (walkTimer < 0)
     {
         walkTimer = 0;
     }
 
     if(isRunning == true)
     {
         walkcool = 0.4;
         walksound();
     }
 
     else
     {
         walkcool = 0.6;
     }
 }
 
 function WalkSound()
 {
     if(walkTimer == 0)
     {
         audio.PlayOneShot(walksound);
         walkTimer = walkcool;
     }
 }

Comment
Add comment · Show 10
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image jmparavicini · Oct 01, 2014 at 12:40 AM 0
Share

you actually have stolen $$anonymous$$Y script

avatar image jmparavicini · Oct 01, 2014 at 12:40 AM 0
Share

you even changed the var names

avatar image jmparavicini · Oct 01, 2014 at 12:41 AM 0
Share

naaa your welcome if i helped you in any way :D

avatar image kingofstreets · Oct 01, 2014 at 12:43 AM 0
Share

Lol are u sure they are yours? i downloaded them off youtube then edited to fit what i neeeded them for xD

avatar image AlucardJay · Oct 01, 2014 at 06:28 AM 1
Share

umm, here is my original script : http://answers.unity3d.com/questions/373508/footsteps-script-for-running-and-walking.html

and here is my edit that includes a sprint timer : http://answers.unity3d.com/questions/596645/limited-sprint.html

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Wiki

Answer by jmparavicini · Oct 01, 2014 at 01:02 AM

try something like this

 #pragma strict
 
 var walksound : AudioClip;
 
 var isWalking : boolean = false;
 var isRunning : boolean = false;
  
 var walkcool : float = 0.6;
 var walkTimer : float = 0;
 
 private var charMotor : CharacterMotor;
 private var charController : CharacerController;
 
 function Start()
 {
     charMotor = GetComponent(CharacterMotor);
     charController = GetComponent(CharacterController);
 }
 
 function Update()
 {
     //change the volume here
     audio.volume = 0.5;
 
    
   if(isRunning == true)
     {
         walkcool = 0.4;
         walksound();
     }
 
     if(isWalking == true)
     {
         walkcool = 0.6;
         walksound();
     }
 
    if(charController.isGrounded && Input.GetKey("left shift") || Input.GetKey("right shift") && Input.GetKey(KeyCode.W));
    {
        isRunning = true;
        isWalking = false;
    }
 
    if(charController.isGrounded && Input.GetKey(KeyCode.E))
    {
        isRunning = false;
        isWalking = true;
    }
 
    if(walkTimer > 0)
     {
         walkTimer -= Time.deltaTime;
     }
  
     if (walkTimer < 0)
     {
         walkTimer = 0;
     }
 }
 
 function WalkSound()
 {
     if(walkTimer == 0)
     {
         audio.PlayOneShot(walksound);
         walkTimer = walkcool;
     }
 }

maybe i forgot something but its late here in chile and im tired so if something doesnt work just tell me i will correct it tomorrow cheers skullbeats1

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

My game wont start after i click a button 1 Answer

Multiplayer Script error 2 Answers

get all scripts attached to gameobject 2 Answers

2D bullet script errors. 1 Answer

Main Menu Script Issues 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges