I am trying to make a sprint script (C#) for my first person controller. I have the stuff that speeds up the movespeed of the controller, but I want to make it so the camera will rotate left, and right, or up and down, to simulate moving your head when running. I tried using the transform.Rotate thing, but I don’t know enough about it. Is there an easier way to move the camera? Can you show me how?
Btw, here’s my script for speeding up the controller.
using UnityEngine;
using System.Collections;
public class SprintScript : MonoBehaviour {
// Update is called once per frame
void Update () {
CharacterMotor Mtr = GetComponent<CharacterMotor>();
if(Input.GetKeyDown (KeyCode.LeftShift))
{
Mtr.movement.maxForwardSpeed = 7;
Mtr.movement.gravity = 40;
}
if(Input.GetKeyUp (KeyCode.LeftShift))
{
Mtr.movement.maxForwardSpeed = 2.5f;
Mtr.movement.gravity = 40;
}
}
}