- Home /
Question by
Bincredible · Nov 03, 2013 at 02:16 AM ·
animationraycastvector3charactermotorgetkeyup
I need help with Jump animations
Hey, I want to know why this code wont work, basically if you press space when grounded you make the initial jump animation, but if the altitude is greater than 4, then if you press space again you will front flip. But what's happening is when you press space when grounded the first animation won't play. And neither will the second. Any help would be nice! Here is my script :
var dJ : boolean;
var j : boolean;
private var motor : CharacterMotor;
function Start(){
motor = GetComponent(CharacterMotor);
}
function Update(){
if(dJ){
animation.CrossFade("_Jump__from_running__Front_flip");
animation["_Jump__from_running__Front_flip"].speed = 3.0;
dJ = false;
}
if(j){
animation.CrossFade("_Jump__from_running_");
animation["_Jump__from_running_"].speed = 3.0;
j = false;
}
var hit : RaycastHit;
if (Physics.Raycast (transform.position, -Vector3.up, hit, 100.0)) {
var altitude = hit.distance;
}
if(!motor.grounded && altitude > 3){
if(Input.GetKeyUp(KeyCode.Space)){
dJ = true;
j = false;
}
}
if(motor.grounded){
if(Input.GetKeyUp(KeyCode.Space)){
j = true;
dj = false;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Door only opening once on Raycast 1 Answer
Loop animation until character reaches hit.point 1 Answer
Help With Animation Play Back - Reverse 1 Answer
How to make char animation idle 0 Answers