Search Unity

How to? Camera boundaries for 2.5D side scroller.

Discussion in 'Scripting' started by mrd777, May 27, 2017.

  1. mrd777

    mrd777

    Joined:
    May 4, 2017
    Posts:
    56
    Hi there,

    Working on my first 2.5D side scrolling and I'm wondering if anyone has any ideas on the best method to stop camera from moving beyond set boundaries?

    Basically, the camera follow the character and has them placed in the center. But when I reach a floor, I don't want half my screen showing an empty floor. Therefore, the camera should detect a bonudary and offset higher so the player sees the play area more in this case. Same thing with the side walls.

    My only idea at this time is to have empty game objects with a trigger collider which detect player distance and offset camera position based on that. However, that means I might have something like 10 of these detection points always polling per frame, checking if player is in range to them, and then sending the offset to the camera.

    Any ideas on a better approach?

    Thanks!
    Dave