Question by
Kartog22 · Apr 03, 2017 at 10:33 PM ·
javascript-specific
How to integrate jump into this script?
I'm using a script that came with a character from the asset store. Since all his animations and everything is already programmed in javascript. If i can see it right, he just plays the animation while some kind of collider or whatever is attached to him stays in same position but the body moves up a bit. Anyway...
#pragma strict
internal var animator:Animator;
var v:float;
var h:float;
var run:float;
var jumpHeight = 8; // MY ATTEMPT
private var isFalling = false;
function Start () {
animator=GetComponent (Animator);
}
function Update () {
v=Input.GetAxis("Vertical");
h=Input.GetAxis("Horizontal");
if (animator.GetFloat("Run")==0.2){
if (Input.GetKeyDown(KeyCode.Space)){
GetComponent.<Rigidbody>().velocity.y = jumpHeight;// MY ATTEMPT
animator.SetBool("Jump",true);
}
}
Sprinting();
}
function FixedUpdate (){
animator.SetFloat("Walk",v);
animator.SetFloat("Run",run);
animator.SetFloat("Turn",h);
}
function Sprinting(){
if (Input.GetKey(KeyCode.LeftShift)){
run=0.2;
}
else
{
run=0.0;
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612114618im_/https://answers.unity.com/themes/thub/images/avi.jpg)