using UnityEngine;
using System.Collections;
[RequireComponent (typeof(CharacterController))]
public class NewBehaviourScript : MonoBehaviour {
public float movementspeed = 5.0f;
public float MouseSensitivity = 5.0f;
public float JumpSpeed = 20.0f;
float verticalrotation = 0f;
public float UpDownRange = 60.0f;
float verticalvelocity = 0f;
CharacterController characterController;
// Use this for initialization
void Start () {
CharacterController characterController = GetComponent<CharacterController> ();
//this hides the mouse
Screen.lockCursor = true;
}
// Update is called once per frame
void Update () {
//Movement with mouse across screen
float rotleftright = Input.GetAxis ("Mouse X")*MouseSensitivity;
transform.Rotate(0.0f ,rotleftright,0.0f);
//movement of mouse up and down
verticalrotation -= Input.GetAxis ("Mouse Y") * MouseSensitivity;
verticalrotation = Mathf.Clamp (verticalrotation, -UpDownRange, UpDownRange);
Camera.main.transform.localRotation = Quaternion.Euler(verticalrotation, 0, 0);
// This is all movement coding
float ForwardSpeed = Input.GetAxis("Vertical")* movementspeed;
float sidespeed = Input.GetAxis("Horizontal")* movementspeed;
verticalvelocity += Physics.gravity.y * Time.deltaTime;
if (cc.isGrounded && Input.GetButtonDown ("Jump")) {
verticalvelocity = JumpSpeed;
}
Vector3 speed = new Vector3 (sidespeed, verticalvelocity, ForwardSpeed);
speed = transform.rotation * speed;
cc.Move(speed * Time.deltaTime );
}
}
These are the errors -Assets/Scripts/NewBehaviourScript.cs(15,37): warning CS0219: The variable `characterController’ is assigned but its value is never used
-Assets/Scripts/NewBehaviourScript.cs(41,21): error CS0103: The name `cc’ does not exist in the current context
-Assets/Scripts/NewBehaviourScript.cs(50,17): error CS0103: The name `cc’ does not exist in the current context
Sorry but im trying to make the CC more efficient and got stuck can anbody help me?
Sorry if im asking too many questions
I did that but it came up with new errors about how cc does not have an assigned value?
– Georgantic