Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Keeping character in bounds of camera

Discussion in 'iOS and tvOS' started by sparkyman, Oct 20, 2009.

  1. sparkyman

    sparkyman

    Joined:
    May 3, 2009
    Posts:
    21
    Hi All

    I am designing a 2d game which has a scrolling scene , my character and camera move along the scene from left to right at a constant speed. I am using the joystick script to move the character up/down/left/right but i can move the character off the screen and I want to keep it in the camera view. I am wanting to know the best way to stop the character moving off the screen whilst allowing the character to continue moving along the scene.

    Cheers
     
  2. Lostlogic

    Lostlogic

    Joined:
    Sep 6, 2009
    Posts:
    693
    You could un-project the character and check if their position is off-screen. If it is you can move the camera accordingly to keep them on-screen. That's how I do it in XNA for the 360 at least.