In the official island demo the First person Camera has extremely jerky movement which I've never been able to figure out. I've trawled the forums for days not believing that I'm the only one to notice this or have the issue. All the demos utilising the FPS script exhibit this problem.
The closest answer I've found is to put all all camera movement into FixedUpdate. Which I think I did, but no change. I edited all the scripts Mouselook, FPSWalker etc to use FixedUpdate. Is that the right thing to do? It made no difference to the poor camera movement. Could someone explain how to implement a solution to get a smooth FPS camera result in a demo.
Coming from Blitz3D I'd implement a smoothing queue or damping etc. I just refuse to believe this technology is demoed with such a rubbish camera script and movement, please let me into the secret.
Must be something in your system, because there's nothing jerky about it here or on any other computer I've used. Putting a first-person camera script in FixedUpdate is not the right thing to do...that will make it only update when the physics system updates, instead of every frame. Try turning off any mouse hacks or utilities you might be using.
Searching the forums I found the following script and it solved my FPS camera movement (I’ve made some adaptations to the original script to fit my needs. Sorry, I don’t know who the author is).
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class SmoothMouseLook : MonoBehaviour
{
/*
This script is used to average the mouse input over x
amount of frames in order to create a smooth mouselook.
*/
//Mouse look sensitivity
public float sensitivityX = 2f;
public float sensitivityY = 2f;
//Default mouse sensitivity
public float defaultSensX = 2f;
public float defaultSensY = 2f;
//Minimum angle you can look up
public float minimumY = -60f;
public float maximumY = 60f;
//Number of frames to be averaged, used for smoothing mouselook
public int frameCounterX = 35;
public int frameCounterY = 35;
//Mouse rotation input
private float rotationX = 0f;
private float rotationY = 0f;
//Used to calculate the rotation of this object
private Quaternion xQuaternion;
private Quaternion yQuaternion;
private Quaternion originalRotation;
//Array of rotations to be averaged
private List<float> rotArrayX = new List<float> ();
private List<float> rotArrayY = new List<float> ();
void Start ()
{
//Lock/Hide cursor
Screen.lockCursor = true;
if (rigidbody)
rigidbody.freezeRotation = true;
originalRotation = transform.localRotation;
}
void Update ()
{
if (Screen.lockCursor) {
//Mouse/Camera Movement Smoothing:
//Average rotationX for smooth mouselook
float rotAverageX = 0f;
rotationX += Input.GetAxis ("Mouse X") * sensitivityX;
//Add the current rotation to the array, at the last position
rotArrayX.Add (rotationX);
//Reached max number of steps? Remove the oldest rotation from the array
if (rotArrayX.Count >= frameCounterX) {
rotArrayX.RemoveAt (0);
}
//Add all of these rotations together
for (int i_counterX = 0; i_counterX < rotArrayX.Count; i_counterX++) {
//Loop through the array
rotAverageX += rotArrayX[i_counterX];
}
//Now divide by the number of rotations by the number of elements to get the average
rotAverageX /= rotArrayX.Count;
//Average rotationY, same process as above
float rotAverageY = 0;
rotationY += Input.GetAxis ("Mouse Y") * sensitivityY;
rotationY = ClampAngle (rotationY, minimumY, maximumY);
rotArrayY.Add (rotationY);
if (rotArrayY.Count >= frameCounterY) {
rotArrayY.RemoveAt (0);
}
for (int i_counterY = 0; i_counterY < rotArrayY.Count; i_counterY++) {
rotAverageY += rotArrayY[i_counterY];
}
rotAverageY /= rotArrayY.Count;
//Apply and rotate this object
xQuaternion = Quaternion.AngleAxis (rotAverageX, Vector3.up);
yQuaternion = Quaternion.AngleAxis (rotAverageY, Vector3.left);
transform.localRotation = originalRotation * xQuaternion * yQuaternion;
}
}
private float ClampAngle (float angle, float min, float max)
{
if (angle < -360f)
angle += 360f;
if (angle > 360f)
angle -= 360f;
return Mathf.Clamp (angle, min, max);
}
}
Steps to use it:
Add a First Person Controller to the scene and remove the Mouse Look script all together
Attach Smooth Mouse Look to the Character Controller with this parameters:
Sensitivity X: 4
Sensitivity Y: 0
Default Sens X: 4
Default Sens Y: 0
Minimum Y: 0
Maximum Y: 0
Frame Counter X: 20
Frame Counter Y: 20
Attach another Smooth Mouse Look to the Main Camera with this parameters:
Sensitivity X: 0
Sensitivity Y: 5
Default Sens X: 0
Default Sens Y: 5
Minimum Y: -60
Maximum Y: 60
Frame Counter X: 20
Frame Counter Y: 20
I have the exact same problem as the person wrote above. I once had Unity on an old machine and it was a bit jumpy then. I now have a Core i3 computer with Intel HD graphics and it is very jerky. I have gone through all the graphics settings but it hasn't changed anything.