- Home /
Question by
game_dev23 · Aug 19, 2018 at 04:09 PM ·
camera-movementbounds
Limit camera from start to end of map sprite
I've been struggling to limit my camera movement to the end of my map and wanted to see if my calculations were right. Turns out when I used Debug.DrawLine(spriteRenderer1.bounds.min, spriteRenderer2.bounds.max, Color.red, 15f) the line wasn't drawn across the two objects!! Why doesn't this work??
As you can see, the the map is repeating. 2nd one is duplicate of the first. The code to reference the map is:
public GameObject firstMap;
public GameObject lastMap;
spriteRenderer1 = firstMap.GetComponent<SpriteRenderer>();
spriteRenderer2 = lastMap.GetComponent<SpriteRenderer>();
firstMap is the first map in my scene and lastMap is the last map in scene.
What I want to do is limit my camera to not go below the x value of beginning of my first map and not to exceed the x value of the end of my last map, regardless of how many maps are in between. Please help, been struggling for weeks with this.
problem2.png
(117.0 kB)
Comment