Need help with animation script

Hey guys, I need help with my JavaScript I’m working on for started and stoping the walk animation for my character whenever the key is pressed down and then let up. Also I have a separate script for the idle animation that is a bit buggy as well so if you guys could help me implement them both together so its just one script that would be great!

Walking Script

function Update()
{
 if(Input.GetKeyDown("w"))
 {
  // Plays the walkinganimation animation- stops all other animations
  animation.Play("walkinganimation", PlayMode.StopAll);

{    
 (Input.GetKeyUp("w")):
 {
  // Plays the walkinganimation animation- stops all other animations
 (AnimationState.Play("walkinganimation")):
 {
  animation.Stop("walkinganimation"):
 }
}[/SUB]

Idle Script
[SUB]   
function Update()
{
 if(Input.GetKeyUp("w"))
{
  // Plays the walkinganimation animation- stops all other animations
  animation.Play("walkinganimation", PlayMode.StopSameLayer);
 }
}

Idle Script

function Update()
{
 if(Input.GetKeyUp("w"))
{
  // Plays the walkinganimation animation- stops all other animations
  animation.Play("walkinganimation", PlayMode.StopSameLayer);
 }
}

Thanks :slight_smile:

Edit: This is the error for the walking script I’m getting

Assests/Character/walkingscript.js(15,2): BCE0043: Unexpected token: }.
Assests/Character/walkingscript.js(17,1): BCE0044: expecting }, found ".

So I know its something with how I’m ending the script, but not sure what to put, I’m new to scripting.

Ignore this reply.

Anyone at all??

Try this(not tested)

//the object with animations attached
var object : GameObject;

function Update()
{
   if(Input.GetKeyDown("w"))
     {
       object.animation.Crossfade("walkinganimation");
     }

   else
      {
        object.animation.Crossfade("Idle");
      }
}

Thanks! I’ll try it out