so I have a character walking around however when i try and jump its jerky …like my character just jumps up and then falls straight back down fast …its like it pops its head up and down really quickly
its like a little spasm up and then down really fast
using UnityEngine;
using System.Collections;
public class CharacterCont : MonoBehaviour {
public float movespeed = 10.0f;
public float mouseSensitivity = 6.0f;
float verticalRotation = 0;
public float upDownRange = 60.0f;
float verticalVelocity = 0;
public float jumpheight = 15.0f;
// Use this for initialization
void Start () {
;
}
// Update is called once per frame
void Update() {
CharacterController cc = transform.GetComponent<CharacterController>();
//mouse look
float rotLeftRight = Input.GetAxis("Mouse X") * mouseSensitivity;
transform.Rotate(0, rotLeftRight, 0);
verticalRotation -= Input.GetAxis("Mouse Y") * mouseSensitivity;
verticalRotation = Mathf.Clamp(verticalRotation, -upDownRange, upDownRange);
Camera.main.transform.localRotation = Quaternion.Euler(verticalRotation, 0, 0);
//movement
float Fspeed = Input.GetAxis ("Vertical") * movespeed * Time.deltaTime;
float Sspeed = Input.GetAxis ("Horizontal") * movespeed * Time.deltaTime;
verticalVelocity += Physics.gravity.y * Time.deltaTime;
if( cc.isGrounded && Input.GetButton("Jump") ) {
verticalVelocity = jumpheight * Time.deltaTime;
}
Vector3 speed = new Vector3( Sspeed, verticalVelocity, Fspeed );
speed = transform.rotation * speed;
cc.Move (speed);
}
can i have solutions in c# only please