- Home /
Question by
kp8680 · Jan 31, 2013 at 12:57 AM ·
c#camerarotatefirstpersoncontroller
Sprinting camera movement? (C#)
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;
}
}
}
Comment
Answer by iwaldrop · Jan 31, 2013 at 05:07 AM
Camera work is the hardest part of making a game IMO. Sadly, this question has been answered before...
http://answers.unity3d.com/questions/46705/fps-hands-and-gun.html