using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FpsCamera : MonoBehaviour {
private Vector2 mouseLook;
private float swipeResistence = 200;
Vector2 smoothV;
public float sentitivity = 5.0f;
public float smoothing = 2.0f;
GameObject character;
// Use this for initialization
void Start ()
{
character = this.transform.parent.gameObject;
}
// Update is called once per frame
void Update ()
{
if (Input.GetMouseButtonDown (0))
{
var md = new Vector2 (Input.GetAxis ("Vertical"), Input.GetAxis ("Horizontal"));
md = Vector2.Scale (md, new Vector2 (sentitivity * smoothing, sentitivity * smoothing));
smoothV.x = Mathf.Lerp (smoothV.x, md.x, 1f / smoothing);
smoothV.y = Mathf.Lerp (smoothV.y, md.y, 1f / smoothing);
mouseLook += smoothV;
transform.localRotation = Quaternion.AngleAxis (-mouseLook.x, Vector3.right);
character.transform.localRotation = Quaternion.AngleAxis (mouseLook.y, character.transform.up);
}
}
}