Hey Guys, I’m trying to create a wall jump script that I have been stuck on for a while. I’m pretty new to using unityscript and coding in general and I’m trying to figure it out. Currently I am using the platformer controller that comes with unity script but I am trying to add this script to my object so he can wall jump. Thanks for your help.
private var canWallJumpDir : Vector3 = Vector3.zero;
private var moveDirection : Vector3 = Vector3.zero;
var speed : float = 26.0;
var jumpSpeed : float = 500.0;
var gravity : float = 20.0;
function Update () {
var fwd = transform.TransformDirection (Vector3.forward);
var controller : CharacterController = GetComponent(CharacterController);
if (controller.isGrounded == false){
// canWallJumpTime = Time.time;
moveDirection = Vector3(Input.GetAxis("Vertical"),0);
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
if(Physics.Raycast(transform.position, fwd, 1 && Input.GetButton("Jump"))) {
print("There is something in front of the object!");
moveDirection.y = jumpSpeed;
}
else{
print ("We are grounded");
}
}
// apply gravity
moveDirection.y -= gravity * Time.deltaTime;
// Move The controller
controller.Move(moveDirection * Time.deltaTime);
}
@script RequireComponent (CharacterMotor)