I want to make it such that it only moves in positive y direction as the player moves forward like in games like color switch and amazing bricks
This is the script I am using currently if follows the player in both the positive and negative y directions.
using UnityEngine;
using System.Collections;
public class CameraController : MonoBehaviour {
public PlayerController thePlayer;
private Vector3 lastPlayerPosition;
private float distanceToMove;
// Use this for initialization
void Start () {
thePlayer = FindObjectOfType<PlayerController>();
lastPlayerPosition = thePlayer.transform.position;
}
// Update is called once per frame
void Update ()
{
distanceToMove = thePlayer.transform.position.y - lastPlayerPosition.y;
transform.position = new Vector3(transform.position.x, transform.position.y + distanceToMove, transform.position.z);
lastPlayerPosition = thePlayer.transform.position;
}
}