I added enum with all the views options. But when i click/press on V nothing happen with the game is running.
using UnityEngine;
public class FollowTargetCamera : MonoBehaviour
{
public enum Views
{
Forward, Backward, Left, Right
}
public Transform Target;
public float PositionFolowForce = 5f;
public float RotationFolowForce = 5f;
public Views views;
void Start()
{
}
void FixedUpdate()
{
Vector3 vector = new Vector3(0, 0, 0);
Vector3 dir = new Vector3(0, 0, 0);
if (Input.GetKeyDown(KeyCode.V))
{
switch (views)
{
case Views.Backward:
vector = Vector3.back;
dir = Target.rotation * Vector3.back;
break;
case Views.Forward:
vector = Vector3.forward;
dir = Target.rotation * Vector3.forward;
break;
case Views.Left:
vector = Vector3.left;
dir = Target.rotation * Vector3.left;
break;
case Views.Right:
vector = Vector3.right;
dir = Target.rotation * Vector3.right;
break;
}
}
dir.y = 0f;
if (dir.magnitude > 0f) vector = dir / dir.magnitude;
transform.position = Vector3.Lerp(transform.position, Target.position, PositionFolowForce * Time.deltaTime);
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(vector), RotationFolowForce * Time.deltaTime);
}
}