- Home /
 
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;
     }
 }
 
              Lol are u sure they are yours? i downloaded them off youtube then edited to fit what i neeeded them for xD
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
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
Your answer
 
             Follow this Question
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