So, I need to use LShift to run, but I can’t exactly figure out how to do so….
I don’t know what to use….
Here my code:
using UnityEngine; using System.Collections; // This script moves the character controller forward // and sideways based on the arrow keys. // It also jumps when pressing space. // Make sure to attach a character controller to the same game object. // It is recommended that you make only one call to Move or SimpleMove per frame. public class Move : MonoBehaviour { CharacterController characterController; public float speed = 6.0f; public float jumpSpeed = 8.0f; public float gravity = 20.0f; public Transform charBody; private Vector3 moveDirection = Vector3.zero; public float mouseSense = 11f; public float runSpeed = 12f; public bool isRunning = false; void Start() { characterController = GetComponent<CharacterController>(); } void Update() { if (characterController.isGrounded) { // We are grounded, so recalculate // move direction directly from axes moveDirection = transform.forward * Input.GetAxis("Horizontal") + transform.right * Input.GetAxis("Vertical"); moveDirection *= speed; moveDirection = transform.right * Input.GetAxis("Horizontal") + transform.right * Input.GetAxis("Vertical"); moveDirection *= speed; if (Input.GetButton("Jump")) { moveDirection.y = jumpSpeed; } } // Apply gravity. Gravity is multiplied by deltaTime twice (once here, and once below // when the moveDirection is multiplied by deltaTime). This is because gravity should be applied // as an acceleration (ms^-2) moveDirection.y -= gravity * Time.deltaTime; // Move the controller characterController.Move(moveDirection * Time.deltaTime); float MOUSEY = Input.GetAxis("Mouse Y") * mouseSense * Time.deltaTime; float MOUSEX = Input.GetAxis("Mouse X") * mouseSense * Time.deltaTime; charBody.Rotate(Vector3.up * MOUSEX); } }
So, when left shift is clicked I want the speed to change to runSpeed…
Can I please have some help doing so?
Thanks