Help with Mecinam script setbool true/false function for jump.(Javascript)

Hey all, been learning unity4 and java-script for the last 6 months. I have now come to a halt, which is un-fortunate because i had it working yesterday.started fiddling around with it today and mucked some things up/around and now i cant remember how i had it in the first place.the state machines and blend trees all work properly its just the script that’s giving me a head ache.( i apolagise in advance for poor spelling and/or the confusing layout of my question.

this is my script that is running my animator controller

#pragma strict

var h : float;
var v : float;
internal var animator : Animator;

function Start () {
	animator  = GetComponent(Animator);
}

function Update () {
	
	h = Input.GetAxis ("Horizontal");
	v = Input.GetAxis ("Vertical");
	
	animator.SetFloat("Speed", v);
	animator.SetFloat("Direction", h);
}

I wanted to add the jump state which was an if and else statement but i cant remember how i put it in the first place. i had a look through previous posts and tried a few different things but nothing has worked i tried this bit of code.

if (Input.GetButtonDown("Jump"))
        animator.SetBool("Jump",true);


else
    animator.SetBool("Jump",false);

I inserted it at the end of my previous script. i also tried.

function Update () {
 
if(Input.GetButtonDown("Jump")) {
animator.SetBool("Jump", true);
}
else {
animator.SetBool("Jump", false);
}
}

function SetJump(value: boolean) {
Jump = value;
animator.SetBool(“Jump”, value);
}

but that didn’t work ether. im not sure what or if i needed to change anything in

function SetJump(value: boolean) {
Jump = value;
animator.SetBool("Jump", value);
}

i also tried

Input.GetKeyDown

as well just to be safe

Im prity sure i had an animator statement of some kind before my if/else script that accesses the animator again but i cant remember. I should’ve saved a copy before i messed with it.

if anyone can help with this Thank you very much.

GetInputButtonDown will only return true as long as the button is down. In general you don’t immediately want to set Jump=false but wait for the animator to stop playing the animation on that state - use an event on the animation like “OnJumpStopped” and then in your method maintain set the parameter.

Thank you for your help i figured out what i did before it was simple really.( hate when that happens)

#pragma strict
internal var animator : Animator;
 
	
function Start () 
{
	animator  = GetComponent(Animator);
}

function Update () 
{


if(animator) 
	if(Input.GetButtonDown("Jump")) animator.SetBool("Jump",true);
	else animator.SetBool("Jump", false);
}

Works like a charm.
The way i set up the "“jump” Boolean is “jump” true then exit time that way the animation only plays once when space bar is taped.