The camera follows player perfectely fine, but I don’t know how to make it move only on Y axis. (code taken from a tutorial video from youtube). Can you help me modify the code so it works as I want it to work?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraFollow : MonoBehaviour
{
public float FollowSpeed = 2f;
public float yOffset = 1f;
public Transform target;
// Update is called once per frame
void Update()
{
Vector3 newPos = new Vector3(target.position.x, target.position.y + yOffset, -10f);
transform.position = Vector3.Slerp(transform.position, newPos, FollowSpeed * Time.deltaTime);
}
}