Hey guys. Im making a copycat of flappy bird called jumpy chicken and now I got a little problem, because I
m not a great coder. I want to let the main camera track the bird and I also made a little script for that which worked, but I don`t want that the camera tracks him in the middle, but a little bit more in front (Just like by the original flappy bird). I know I need to change the x position of the camera, but how?
My script:
Transform Player;
float offsetX;
// Use this for initialization
void Start () {
GameObject player_go = GameObject.FindGameObjectWithTag ("Player");
if (player_go == null) {
Debug.LogError("Couldn`t find an object with tag `Player` !");
return;
}
Player = player_go.transform;
offsetX = Player.position.x - Player.position.x;
}
// Update is called once per frame
void Update () {
if (Player != null) {
Vector3 pos = transform.position;
pos.x = Player.position.x + offsetX;
transform.position = pos;
}
}
Help would be appreciated