So basically I have two cameras in the scene, one third person camera(tpcam) and one first person camera(fpcam).
The default view is FPS, I want when you hit V for the tpcam to snap to the location/rotation of the fpcam. Then smoothly move back to it’s original position/rotation.
So as to simulate a smooth transition from fpcam to tpcam.
I’m using two cameras because the equipped weapon is parented to the fpcam.
This script is on the tpcam, the code that actually toggles the cameras is elsewhere on the fpcam. Which is just a simple boolean
if (Input.GetButtonDown ("View"))
{
fpsCam = !fpsCam;
}
======>Only Problem I’m having here is with the smoothdamp code, I can’t figure out how to pass vector3 positions into it, as I think it only takes floats<======
Here’s my error message that occurs on line of the mathf.smoothdamp;
– Assets/-Scripts/tpCAimAssist.js(40,44): BCE0023: No appropriate version of ‘UnityEngine.Mathf.SmoothDamp’ for the argument list ‘(UnityEngine.Vector3, UnityEngine.Vector3, float, float)’ was found. –
Here’s the code;
public var fpCamera : Camera; //Used for Switching between 1st/3rd person view
public var tpCamera : Camera;
public var camTransVel : float = 1.0; //Smooth Velocity
public var smoothTime : float = 1.0;
private var fpCamPos : Vector3; //Camera positions
private var tpCamPos : Vector3;
private var tpCamRot : Quaternion;
function Update()
{
//If Button is pressed switch between 1st/3rd person view
if (head.GetComponent("CameraLook").fpsCam == false)
{
//Store current tpCamPossition
fpCamPos = fpCamera.transform.position;
tpCamPos = tpCamera.transform.position;
tpCamRot = tpCamera.transform.rotation;
//Snap tpsCam to fpsCam pos and rot
tpCamera.transform.position = fpCamera.transform.position;
tpCamera.transform.rotation = fpCamera.transform.rotation;
//Smoothly move tpCam back to its pos
var newPosition = Mathf.SmoothDamp (fpCamPos, tpCamPos,camTransVel, smoothTime);
tpsCamPos = tpCamera.transform.position = newPosition;
//Turn tpCam on and fpCam off
fpCamera.camera.enabled = false;
tpCamera.camera.enabled = true;
}
}
If you have any input at all on this it’s much apreciated, I’ve been stumped for hours now.