I created a LookAt function but the camera does not look at the car that I'm using. BTW I'm following a tutorial

This is the code I wrote:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraThing : MonoBehaviour
{
    public float input;

    public GameObject player;

    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player");
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        input = Input.GetAxis("Horizontal");

        gameObject.transform.localPosition = new Vector3(gameObject.transform.localPosition.x + input, gameObject.transform.localPosition.y , gameObject.transform.localPosition.z);
        gameObject.transform.LookAt(player.transform.position);
    }
}

If you notice anything wrong pls tell me. thx

I’m not sure if this is what you wanted to achieve, but I think the issue was, that you were using transform.localPosition instead of transform.position. Also, you don’t need gameObject when you want to reference transform, you can use them separately. You were also using FixedUpdate - which is for physics - instead of LateUpdate - which runs after everything finished in all other XY Updatemethods

I tested your script and for me pushing A and D (or left and right arrow), will make the camera zoom in and out on Player. Here’s the corrected script

using UnityEngine;
 
public class CameraThing : MonoBehaviour
{
    public float input;
 
    public GameObject player;
 
    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player");
    }
 
    // Update is called once per frame
    void LateUpdate()
    {
        input = Input.GetAxis("Horizontal");
 
        transform.position = new Vector3(transform.position.x + input, transform.position.y , transform.position.z);
        transform.LookAt(player.transform.position);
    }
}

Thank u so much!