So I’m new to unity and I have been researching double jump for a while. It’s apparently difficult… at least it is for me… So I have set up a custom Player Controller script, a rigid body, and a Character Controller (which I don’t think I am even using anymore…). I am not brand new to JS but I am not exactly a seasoned veteran when it comes to actually using it as a scripting language outside of HTML… What I am trying to do is make a simple double jumping character by following other people’s scripts and tutorials, but I am trying to do it my own way, a simpler way, and in general, a different way from which I have seen done. I thought it would be possible to do this with my current setup without having to forfeit what I have already done - however through my struggles I have redone basically everything from scratch anyways…

I digress…

Here is the code for my Script that is supposed to move the Character left and right and allow for double jump if the character is able. Can someone please tell me what I am doing wrong? This is mostly a learning experience. I don’t learn well from Youtube tutorials, so If someone could help me understand what I am doing that would be great!

var autoRotate : boolean = true;
var maxRotationSpeed : float = 360;
var airJumpMax : int = 1;
var jumpForce : float = 8;
var airJumpForce : float = jumpForce * 0.6;
var walkSpeed : float = 8;

private var xMove : int = 0;
private var airJumpAmt : int = 0;
private var isGrounded : boolean = false;

function Awake () {
	motor = GetComponent(CharacterMotor);
}

function Update () {
	//Double jump raycasting
	if(Physics.Raycast(transform.position, -Vector3.up, 1)) {
        isGrounded = true;
        airJumpAmt = airJumpMax;
    }
	if(Input.GetKeyDown(KeyCode.Space)){
       if(isGrounded) {
           JumpNormal();
       }else if(airJumpAmt > 0) {
           airJumpAmt -= 1;
           JumpInAir();
       }
    }
    
    xMove = 0;
    xMove = Input.GetAxisRaw("Horizontal") * walkSpeed;
}

function FixedUpdate(){
	rigidbody.velocity = new Vector3(xMove*walkSpeed,0,0);
}

function projectOntoPlane (v : Vector3, normal : Vector3) {
	return v - Vector3.Project(v, normal);
}

function JumpNormal () { rigidbody.AddForce(Vector3.up * jumpForce, ForceMode.Impulse); }
 
function JumpInAir () { rigidbody.AddForce(Vector3.up * airJumpForce, ForceMode.Impulse); }

function constantSlerp (from : Vector3, to : Vector3, angle : float) {
	var value : float = Mathf.Min(1, angle / Vector3.Angle(from, to));
	return Vector3.Slerp(from, to, value);
}

// Require a character controller to be attached to the same game object
@script AddComponentMenu ("Character/Platform Input Controller");

EDIT:
So I had to change some original values a little bit but eventually yes my double jump now works. However I am still having problems moving horizontally. The character, currently, slowly drags to the ground because of this

function FixedUpdate(){ rigidbody.velocity = new Vector3(xMove*walkSpeed,0,0); }

I am not sure how to move my player horizontally, while keeping vertical and horizontal momentum, using my current setup… I do have a character controller in the player too, not just my script, but I haven’t used it because… Well… I don’t know what it does or how to use it.
Basically this script causes the character to slowly, and choppily, sink to the ground from starting position. It cannot jump and cannot move. That is because of what is in the “FixedUpdate” function. I fixed the double jump but the character can’t move left or right without totally spazzing out.

Is your first jump propelling your character more than 1 unit above the ground?

I ask because you are raycasting 1 unit down.
If not, then this clause will never be reached:

   }else if(airJumpAmt > 0) {
       airJumpAmt -= 1;
       JumpInAir();
   }

Your jumpforce is 8, but I don’t know how heavy your rigidbody is, or if you are using normal gravity.
Put a breakpoint on it and find out