- Home /
A good third person follow camera?
I'm wanting to create an "on-rails" experience for the Oculus Rift. The rider is towed behind a flying dragon, much like Santa in his sleigh, behind his reindeer.
I have "attached" a camera to the dragon, and am successfully following it on its flight path, but am having trouble "loosening" the path of the camera so it is not so rigidly following the dragon. I am also having trouble enabling a successful mouse look (that will become the input for the Oculus Rift.) I have played with all of the camera and Mouse Look script included with the Unity Standard Assets, but have no idea how to code.
Can someone set me on the right path to solving these two problems? Should I look for custom scripts or are there certain assets in the store that pertain to exactly what I'm trying to achieve?
Thanks so much!
Answer by TheShadyColombian · Aug 30, 2014 at 07:03 PM
i'm not sure i can post this as i remember seeing it and copying it from somewhere but here is the script i attached to my camera:
//SmoothLookAt.cs
//Written by Jake Bayer
//Written and uploaded November 18, 2012
//This is a modified C# version of the SmoothLookAt JS script. Use it the same way as the Javascript version.
using UnityEngine;
using System.Collections;
///<summary>
///Looks at a target
///</summary>
[AddComponentMenu("Camera-Control/Smooth Look At CS")]
public class SmoothCamera : MonoBehaviour {
public Transform target; //an Object to lock on to
public float damping = 6.0f; //to control the rotation
public bool smooth = true;
public float minDistance = 10.0f; //How far the target is from the camera
public string property = "";
private Color color;
private float alpha = 1.0f;
private Transform _myTransform;
void Awake() {
_myTransform = transform;
}
// Use this for initialization
void Start () {
// if(renderer.material.HasProperty(property)) {
// color = renderer.material.GetColor(property);
// }
// else {
// property = "";
// }
// if(rigidbody) {
// rigidbody.freezeRotation = true;
// }
}
// Update is called once per frame
void Update () {
}
void LateUpdate() {
if(target) {
if(smooth) {
//Look at and dampen the rotation
Quaternion rotation = Quaternion.LookRotation(target.position - _myTransform.position);
_myTransform.rotation = Quaternion.Slerp(_myTransform.rotation, rotation, Time.deltaTime * damping);
}
else { //Just look at
_myTransform.rotation = Quaternion.FromToRotation(-Vector3.forward, (new Vector3(target.position.x, target.position.y, target.position.z) - _myTransform.position).normalized);
float distance = Vector3.Distance(target.position, _myTransform.position);
if(distance < minDistance) {
alpha = Mathf.Lerp(alpha, 0.0f, Time.deltaTime * 2.0f);
}
else {
alpha = Mathf.Lerp(alpha, 1.0f, Time.deltaTime * 2.0f);
}
// if(!string.IsNullOrEmpty(property)) {
// color.a = Mathf.Clamp(alpha, 0.0f, 1.0f);
// renderer.material.SetColor(property, color);
// }
}
}
}
}
Answer by Eric-Eidel · Apr 21, 2016 at 04:49 AM
Hey guys, I know this is a bit old but this is the first result on Google for me and I spent quite the time to find the answer I wanted. Check out this page: https://ruhrnuklear.de/fcc/ for a great implementation and a demo scene on a WOW-like camera and controller.
This is what I was after and it provided me a great starting point! The project is a bit dated, but once you update it for 5.3 it works out of the box! Just wanted to place this here since this is the top google result, in case someone else is looking for a wow-like camera (yes, cliche, but it's the best MMO camera controls out there imho).
Answer by dullmist861357 · Mar 16, 2017 at 08:24 PM
add a simple mouse rotator and set the Y axis to a low number such as ten. If you set the Y to say 1 and the x to say zero (y is left and right and x is up and down) you will have small movements, but can't look around too much. Should stop it being all sharp. Should work. @saucer78
Your answer
Follow this Question
Related Questions
Explaining A Mouse Look Script 1 Answer
Controls Like the Mouse Look. Just without using Mouse 1 Answer
camera follow problem 4 Answers
How do I disable 2D camera follow when my player collides with a trigger object? 0 Answers
How to set the follow distance to a target object when using the “Multipurpose Camera Rig”? 3 Answers