Making Jump script along Z axis
YouTube hasn’t helped
This is what i have so far…
Reference of current script
public int Gravity = 0;
public bool CanJump = true;
public CharacterController controller;
private Vector3 MoveDirection = Vector3.zero;
public int JumpHeight = 5;
if (CanJump Input.GetKey ("space"))
{
MoveDirection.z = JumpHeight;
}
MoveDirection.z -= Gravity * Time.deltaTime;
controller.Move (MoveDirection * Time.deltaTime);
I dont understand from line 8+ and its not working due to CharacterController
Please Explain code from line 8+ and state if anything is wrong.
This script is for a jump 2D top down view game, so the player must jump towards Z axis as Unity is set for 2D