So i am making an Android game in which i want the Camera to follow the Character ONLY on the Z-Axis
I am using this script which makes the character follow the camera but the camera view shifts to the left side of the screen in play mode also it moves on the X-axis along with the character, which i don't want. I want the camera to move only in the Z-axis, also the camera stutters a bit : Here's the script:
using UnityEngine; using System.Collections;
public class CameraController : MonoBehaviour { public GameObject player; private Vector3 offset; // Use this for initialization void Start () { offset= transform.position; }
// Update is called once per frame
void LateUpdate () {
transform.position = player.transform.position+offset;
}
}
Answer by Veerababu.g · Dec 19, 2015 at 05:52 AM
y don't use position for the camera. i mean like
camera.transform.position=new vector3(camera.transform.position.x,camera.transform.position.y,character.transform.position.z-//some distance what u need);
Your answer
Follow this Question
Related Questions
Camera doesnt scale GameObjects when approaching and smudges them 0 Answers
Minimap- in real time. 0 Answers
survival shooter camera problem 0 Answers
Move camera with touch 0 Answers
Help with third person camera 0 Answers