- Home /
Best Answer
Answer by Bunnybomb7670 · May 17, 2013 at 10:07 AM
If your doing this in update, you can possibly keep setting the X and Y axis to 0 at the same time as setting the Z axis towards the object, I am pretty sure it would go like this:
Transform.LookAt(0,0,Target.transform.position.z);
Untested code but that should work.
Answer by herman111 · Jul 24, 2014 at 03:31 PM
using UnityEngine;
using System.Collections;
public class HermeCameraFollow : MonoBehaviour {
// written by herman darr july 20 2014 6:12PM
public Transform playerToFollow;
public Transform farLeft;
public Transform farRight;
void Update () {
if(playerToFollow)
{
Vector3 newPosition = transform.position;
newPosition.z = playerToFollow.position.z;
newPosition.z = Mathf.Clamp(newPosition.z,farLeft.position.z,farRight.position.z);
transform.position = newPosition;
}
}
}
This might work....make 2 empty gameObjects position left and right, where you want them
Answer by yekush · Jul 24, 2014 at 02:09 PM
This is the script I use, Its in Javascript though,
pragma strict
var Target : Transform;
var distance = 1;
function Update () {
transform.position = Target.position + Vector3( 0,0,distance);
transform.LookAt (Target);
}
Your answer
Follow this Question
Related Questions
Camera rotation around player while following. 6 Answers
How to move camera up and down 1 Answer
Camera not moving on mobile 0 Answers
Lock main camera on x-axis 2 Answers