So I would basically like to keep a moving object to stay inside the camera box but I don’t want the camera to follow this object, Id like it so that the camera is moving along the Y axis and the object can be moved freely within the camera view? How could i achieve this?
camera.ViewportToWorldPoint allows you to transform screen co-ordinates to world co-ordinates. Try using that to keep the character within the bounds of the screen
Unity - Scripting API: Camera.ViewportToWorldPoint
Alternatively you can get the frustum planes from the camera :
Have a good day
Florent
I appreciate the help, but i have figured it out! Wanted to keep it simple, so i came up with this.
public class CameraTracksPLayer : MonoBehaviour {
// Update is called once per frame
void Update ()
{
float camUp = Time.deltaTime * 5;
transform.Translate (0, camUp, 0, Camera.main.transform);
}
}
I just added box colliders around the camera to restrict the player from moving out of it.