character controller wont rise when I Jump :(

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 :slight_smile:

 #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

never mind i found the problem, i used the script here Unity - Scripting API: CharacterController.Move and stuck my animation cross fade in it, i also realised i had to take any gravity effecting script off of my character movement script so my separate jump script dealt with all the gravity uses. heres my script now,

#pragma strict

var speed : float = 6.0;
	var jumpSpeed : float = 8.0;
	var gravity : float = 20.0;

	private var moveDirection : Vector3 = Vector3.zero;

function Start () {

animation["jump"].layer = 2;
}

function Update () { 
var controller : CharacterController = GetComponent(CharacterController);
		if (controller.isGrounded) {
			// We are grounded, so recalculate
			// move direction directly from axes
			moveDirection = Vector3(Input.GetAxis("Horizontal"), 0,
			                        Input.GetAxis("Vertical"));
			moveDirection = transform.TransformDirection(moveDirection);
			moveDirection *= speed;
			
			if (Input.GetButton ("Jump")) {
				moveDirection.y = jumpSpeed;
				animation.CrossFade ("jump");
			}
		}

		// Apply gravity
		moveDirection.y -= gravity * Time.deltaTime;
		
		// Move the controller
		controller.Move(moveDirection * Time.deltaTime);
	}

also I had to play around with the gravity level in the inspector so it fitted my jump animation, i’m gonna leave this on here for people to find who have had similar issues/problems, hope this helps! x