I HAVE THIS WARNING: Assets/Scripts/FirstPersonController.cs(65,23): warning CS0219: The variable `speed’ is assigned but its value is never used
I FOLLOWED THE MIKE GEIG TUTORIAL ABOUT MERRY FRAGMAS AND BECAUSE OF THIS WARNING I CAN’T SPRINT. THE ANIMATION WORK’S, BUT MY SPEED DO NOT INCREASE. HERE IS THE SCRIPT:
using UnityEngine;
using System.Collections;
[RequireComponent (typeof(CharacterController))]
public class FirstPersonController : MonoBehaviour {
public bool walkByDefault = true;
public float runSpeed = 8.0f;
public float movementSpeed = 5.0f;
public float mouseSensitivity = 6.0f;
public float upDownRange = 60.0f;
public float jumpSpeed = 20f;
float verticalVelocity = 0;
CharacterController characterController;
Animator anim;
// Use this for initialization
void Start ()
{
Screen.lockCursor = true;
characterController = GetComponent<CharacterController> ();
}
// Update is called once per frame
void Update ()
{
//Rotation
float rotLeftRight = Input.GetAxis("Mouse X") * mouseSensitivity;
transform.Rotate (0, rotLeftRight, 0);
float rotUpDown = Input.GetAxis("Mouse Y") * mouseSensitivity;
float currentUpDown = Camera.main.transform.rotation.eulerAngles.x;
float desiredUpDown = currentUpDown - rotUpDown;
//desiredUpDown = Mathf.Clamp (desiredUpDown, -upDownRange, upDownRange);
Camera.main.transform.localRotation = Quaternion.Euler(desiredUpDown, 0, 0);
//Movement
float forwardSpeed = Input.GetAxis("Vertical") * movementSpeed;
float sideSpeed = Input.GetAxis("Horizontal") * movementSpeed;
verticalVelocity += Physics.gravity.y * Time.deltaTime;
if ( characterController.isGrounded && Input.GetButtonDown ("Jump")) {
verticalVelocity = jumpSpeed;
}
Vector3 speed = new Vector3 ( sideSpeed, verticalVelocity, forwardSpeed );
speed = transform.rotation * speed;
characterController.Move ( speed * Time.deltaTime);
anim = GetComponentInChildren<Animator> ();
}
public void LateUpdate () {
float speed = runSpeed;
#if !MOBILE_INPUT
// On standalone builds, walk/run speed is modified by a key press.
// We select appropriate speed based on whether we're walking by default, and whether the walk/run toggle button is pressed:
bool walkOrRun = Input.GetKey(KeyCode.LeftShift);
bool aim =Input.GetButton ("Fire2");
if(aim)
walkOrRun =false;
speed = walkByDefault ? (walkOrRun ? runSpeed : movementSpeed) : (walkOrRun ? movementSpeed : runSpeed);
// On mobile, it's controlled in analogue fashion by the v input value, and therefore needs no special handling.
anim.SetBool ("Sprint" , walkOrRun);
anim.SetBool ("Aim", aim);
#endif
}
}
ANY IDEAS?