Hey there. I've been trying to get my camera to smoothly move over the shoulder of my character when the right mouse button is pressed down (Kind of like in the new Tomb Raider. Like an aim or a look function). I've got some stuff written, but I'm really just swinging around blindly. If any of you guys could help me out, that would be much appreciated. Thanks!
using UnityEngine;
using System.Collections;
public class ShoulderCamera : MonoBehaviour {
public GameObject character;
public Camera camera;
public float smoothing = 1;
private Vector3 cIntPos;
private Vector3 cZoomPos;
// Update is called once per frame
void Update () {
if(Input.GetKeyDown ("mouse2")){
camera.transform.position = Vector3.MoveTowards(camera.transform.position,
cIntPos,
Time.deltaTime * smoothing);
}
}
}
Another note, I'm a little scared that this script will conflict with another one that allows for the camera to orbit around the character. I think this can be avoided with a simple if statement, but I'm still a little iffy about it.