so i am making a 3rd person game and my script makes my character movement jerky looking. the script is attached to the camera:
public class camFollow : MonoBehaviour {
public LayerMask mask;
public Transform[] target;
public float height;
public float distance;
public float x;
public float y;
public float yMin;
public float yMax;
int i = 0;
void Update () {
x += 3 * Input.GetAxis ("Mouse X");
y += 3 * -Input.GetAxis ("Mouse Y");
if(y > yMax){
y = yMax;
}
if(y <yMin){
y = yMin;
}
Quaternion rotation = Quaternion.Euler (y, x, 0);
//Quaternion rotation = target*.rotation;*
_ Vector3 pos = rotation * new Vector3(0, height, -distance) + target*.position;*_
* transform.rotation = rotation;*
* transform.position = pos;*
* transform.position = Vector3.Lerp (transform.position, pos, Time.deltaTime);*
_ transform.LookAt (target*);
RaycastHit hit;
if(Physics.Linecast(target.position, transform.position, out hit, mask)){
float tempDistance = Vector3.Distance(target.position, hit.point);
pos = rotation * new Vector3(0, height, -tempDistance) + target.position;
transform.position = pos;
}
}
}*
what should i change to make the movement smooth? (it is the camera making the jerkiness not the animation, also target is an array because there is multiple characters that you can switch through, no i do not want to use the script smoothfollow so don’t suggest it?_