- Home /
Camera not following player.,Camera not following player...
hi, i tried to make my camera follow my player and it worked, but then i tried smoothening it with a Lerp but now it only looks at the player. Here is my script.
using UnityEngine;
public class CameraFollow : MonoBehaviour {
public Transform target;
public float smoothSpeed = 0.125f;
public Vector3 offset;
private void FixedUpdate()
{
Vector3 desiredPosition = target.position + offset;
Vector3 smoothedPosition = Vector3.Lerp(transform.position, desiredPosition, smoothSpeed * Time.deltaTime);
transform.position = smoothedPosition;
transform.LookAt(target);
}
}
Answer by fr0stsp1k3 · Sep 02, 2018 at 07:19 PM
A very easy way to do this - would be, and try this, take the camera object, with your cursor, drag it over the player object, so the player camera becomes a child of the player, that way itll automatically follow it. Hope that helps
Your answer
![](https://koobas.hobune.stream/wayback/20220612173934im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Crouching script not working? 0 Answers
Start Camera Lerp from diffrent script? 1 Answer
Smooth Camera transition (linear interpolation) Error 1 Answer
Orthographic (Birds-Eye View/Top-Down) Player Follow Script w/ Smoothing 2 Answers
Using lerp to go between 3 different locations isn't working 0 Answers