OK so ive gotten the majority of this script to work already and the hard part of detecting the wall with a raycast at 1 meter and detecting whether the player has jumped or not is done and working. The problem i am having is actually getting the player to jump off of the wall in the opposite direction with actual velocity. Right now it seems that when the player jumps off the wall it is simply teleporting the player to a cooridinate pair instead of jumping off the wall smoothly, how do I get the player to jump off the wall normally like when jumping off a smooth surface?
Here is my code so far:
public var jumpSpeed : float = 10.0;
private var jumpDirection : Vector3 = Vector3(10,10,0);
function Update ()
{
var fwd = transform.TransformDirection (Vector3.forward);
var controller : CharacterController = GetComponent(CharacterController);
if (controller.isGrounded != true)
{
if (Physics.Raycast (transform.position, fwd, 1))
{
if (Input.GetButton ("Jump"))
{
print("I am here");
controller.Move(jumpDirection);
}
}
}
}