Good news, I’ve finally got my jump animation working, bad news is I cant jump over obstacles because my character controller wont move when I jump here’s an example,
also if i let go of the directional buttons my character automatically returns to facing forwards whether running or jumping, i’d like to be able to fix that too
#pragma strict
function Start () {
animation["Jump_pose"].layer = 2;
}
function Update () {
if (Input.GetButtonDown ("Jump"))
animation.CrossFade ("Jump_pose");
}
This is my Jump script, above and my character controller script below.
#pragma strict
var rotationSpeed : float = 10;
var walkSpeed : float = 7;
var gravity : float = 50;
private var yRot : float;
var body : Transform;
function Update () {
var Controller : CharacterController = GetComponent(CharacterController);
var vertical : Vector3 = transform.TransformDirection(Vector3.forward);
var horizontal : Vector3 = transform.TransformDirection(Vector3.right);
var height : Vector3 = transform.TransformDirection(Vector3.up);
if(Input.GetAxis("Vertical") || Input.GetAxis("Horizontal")){
animation.CrossFade("walk", 0.2);
animation["walk"].speed = walkSpeed/10;
Controller.Move((vertical *(walkSpeed* Input.GetAxis("Vertical"))) *Time.deltaTime);
Controller.Move((horizontal *(walkSpeed* Input.GetAxis("Horizontal"))) *Time.deltaTime);
}else{
animation.CrossFade("idle", 0.2);
}
if(Input.GetAxis("Mouse X")){
yRot += 10 * Input.GetAxis("Mouse X");
}
Controller.Move(height *-gravity* Time.deltaTime);
}
function LateUpdate(){
if(Input.GetAxis("Vertical") == 0){
if(Input.GetAxis("Horizontal") > 0){
body.localEulerAngles.y = 90;
}else if(Input.GetAxis("Horizontal") < 0){
body.localEulerAngles.y = -90;
}
}else if(Input.GetAxis("Vertical") > 0){
if(Input.GetAxis("Horizontal") > 0){
}else if(Input.GetAxis("Horizontal") < 0){
}
}else if(Input.GetAxis("Vertical") < 0){
if(Input.GetAxis("Horizontal") > 0){
}else if(Input.GetAxis("Horizontal") < 0){
}
}
}
hope someone can help! x