Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Camera that slides to next room

Discussion in 'Scripting' started by hammy2747, Jul 19, 2015.

  1. hammy2747

    hammy2747

    Joined:
    Apr 19, 2014
    Posts:
    19
    Hello, I am working on a 2D roguelike sidescroller, and I am stuck on camera movement. I need it to slide to the next room when ever the player walks up to a door on the left or right side. I was hoping for something like this:
    . I have no progress on this, so any help would be great!
     
  2. phoda

    phoda

    Joined:
    Nov 11, 2014
    Posts:
    384
    If you think changing scenes it would be easier to create like part of the map on isolated part of level.
    If you think slide to next area of level like LINK in canyon you can lerp the vector3 of camera position. Ofcourse you need to calculate how much tiles are in camera scope (from one end of camera to other)

    Lets say your camera sees 10 x tiles .
    in camera script you would move it in update function
    Code (CSharp):
    1. transform.position = new Vector3(startVector, endVector, time);
    2.  
    in unity manual is good example how to setup start, end vector and time.

    Hope it helps :)
     
    hammy2747 likes this.
  3. hammy2747

    hammy2747

    Joined:
    Apr 19, 2014
    Posts:
    19
    Thanks! I will see is that will work :)