- Home /
Question by
VAN-D00M · Jul 14, 2014 at 06:11 PM ·
c#playercamera-movementcamera follow
Follow Camera Interferes with Player Movement?
Hi This is the script attached to the main camera. Its a top down game and the camera is supposed to follow the player.
Instead, it stays where it is and doesn't let the player move around freely. Its like the player is attached to the centre of the screen on a bungie cord which isn't right. Player moves fine when the camera script is turned off.
using System.Collections;
public class CameraMovement : MonoBehaviour
{
private Vector3 cameraTarget;
private Transform target;
void Start()
{
target = GameObject.FindGameObjectWithTag ("Player").transform;
}
void Update()
{
cameraTarget = new Vector3 (target.position.x, transform.position.y, target.position.z);
transform.position = Vector3.Lerp (transform.position, cameraTarget, Time.deltaTime * 2);
}
}
Any ideas whats going wrong? I've this script work for others and similar scripts don't work either.
Harry
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How to undo destroying a component, after 5 seconds. 0 Answers
Finding the player that walked into a ray? 1 Answer
Raycast does not detect Objects 2 Answers
Player enable 1 Answer