I’m having a fairly annoying problem with my character script. Whenever the capsule character hits a wall, it spazzes out a little bit, and sometimes it will start rotating and stuff.
Here’s the script:
void Start () {
transform.position = new Vector3(0,3,3);
Physics.gravity = new Vector3(0,-5,0);
}
void OnCollisionEnter (Collision collision){
grounded = true;
}
void OnCollisionExit (Collision collision){
grounded = false;
}
// Update is called once per frame
void Update () {
if(Input.GetKey ("a")){
transform.Rotate (0, negativeRotationSpeed * Time.deltaTime, 0);
}
if(Input.GetKey ("d")){
transform.Rotate (0, rotationSpeed * Time.deltaTime, 0);
}
if(Input.GetKey ("w")){
transform.Translate (0, 0, speed * Time.deltaTime);
}
if(Input.GetKey ("s")){
transform.Translate (0,0, negSpeed * Time.deltaTime);
}
if(Input.GetButtonDown ("Jump")&& grounded == true){
rigidbody.AddForce (Vector3.up * jump);
}
}
}