Need help to restrict camera not to move outside maps (multiple) within 1 scene (2D top down game)
Hi guys,
I just started unity game development not too long ago, and I have multiple maps in 1 scene. I can have the camera follow my player around just fine, but how do I set the camera to not move outside the map borders?
Also re-adjust camera after player warps from 1 map to another to make sure camera is always inside the map?
Here's what I have for my current camera code:
public class CameraFollow : MonoBehaviour {
public Transform target;
public float m_speed = 0.1f;
Camera myCam;
// Use this for initialization
void Start () {
myCam = GetComponent<Camera>();
}
// Update is called once per frame
void Update () {
myCam.orthographicSize = (Screen.height / 100f) / 4f;
if (target)
transform.position = Vector3.Lerp(transform.position, target.position, m_speed) + new Vector3(0, 0, -10);
}
}
Please do help me and let me know if I have to redesign it to have 1 map per scene
Thanks!
Comment
Your answer

Follow this Question
Related Questions
Set the rotation axis of the camera 0 Answers
Weird Rendering Unity5 1 Answer
How to do a wall jump? i am very novice 0 Answers