Question by
Alkey_Smagul · Nov 14, 2021 at 02:41 PM ·
camera-movementcamera follow
Camera movement by OY coordinate
Hello i have a problem with following camera. It cant follow player by OY coordinate. my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class camera : MonoBehaviour
{
public Transform target;
public Vector3 positionOffset;
public float smooth = 3.0f;
void Start()
{
positionOffset = gameObject.transform.position - target.position;
}
void LateUpdate()
{
transform.position = Vector3.Lerp(transform.position, new Vector3(target.position.x +
positionOffset.x, positionOffset.y, target.position.z + positionOffset.z), Time.deltaTime
* smooth);
}
}
Also link of video where i recorded of my problem:https://youtu.be/0RCEmrw3Xho
Comment