Question by
Bananik_007 · Sep 20, 2016 at 05:12 PM ·
cameracarpublic variable
How to select which camera i want to use.
Sorry for my english I have this script and i want to place this script to my car and select which camera i want to use
using UnityEngine;
using System.Collections;
public class CarCamera2 : MonoBehaviour
{
public Transform target;
public float distance = 3.0f;
public float height = 3.0f;
public float damping = 5.0f;
public bool smoothRotation = true;
public bool followBehind = true;
public float rotationDamping = 10.0f;
void FixedUpdate()
{
Vector3 wantedPosition;
if (followBehind)
wantedPosition = target.TransformPoint(0, height, -distance);
else
wantedPosition = target.TransformPoint(0, height, distance);
transform.position = Vector3.Lerp(transform.position, wantedPosition, Time.deltaTime * damping);
if (smoothRotation)
{
Quaternion wantedRotation = Quaternion.LookRotation(target.position - transform.position, target.up);
transform.rotation = Quaternion.Slerp(transform.rotation, wantedRotation, Time.deltaTime * rotationDamping);
}
else transform.LookAt(target, target.up);
}
}
Comment