Search Unity

Rotate view without rotating scene

Discussion in '2D' started by Chubysnow, Apr 7, 2015.

  1. Chubysnow

    Chubysnow

    Joined:
    Jul 2, 2013
    Posts:
    5
    So I want to rotate the view in the scene so that the player can view farther diagonally. The game is a straight on 2d platformer, so having the extra diagonal view helps. However, trying to rotate the camera causes the entire scene to rotate. I attached in image to clarify. Right now, I have the orientation like in example 1. Rotating the camera's Z rotation (roll) leads to example example 2, but rotates the player sprites unsatisfactorily. What I would like to do is rotate the view of the scene, but not rotate the platform or character, like in example 3.
     

    Attached Files:

  2. Stv3D

    Stv3D

    Joined:
    Dec 10, 2011
    Posts:
    34
    Hey there Chubysnow.

    Is there a game already using this mechanic? Rotating the camera is possible, but to view more is not quite possible.
    If the game is on landscape orientation and you rotate the view you will only create clipping since you are limited by the device screen.
    Following your example:
    screen_rotation.jpg
    The physical device screen size can not change, thus unable to view more.
    If you had square resolution screens you could limit the player intentionally making it a rectangle. Then using 2 cameras or rotation compensation you could achieve the desired effect.
    Instead of diagonal rotation, you could make diagonal camera movement or camera zooming.
     
  3. Chubysnow

    Chubysnow

    Joined:
    Jul 2, 2013
    Posts:
    5
    Thank you for the response, but I am still confused. I don't mind clipping of the left and ride sides in cases where that would give the player more vertical viewing. What I would like is exactly what you drew in purple. If the screen itself is rotated with the camera, wouldn't that prevent clipping?
     
    Last edited: Apr 8, 2015
  4. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    If I understand the end result - you want the environment to be rendered larger than the screen size. So when the camera is rotated via a button or gyroscope or however it's rotated, the scene stays oriented "level" but by turning the device (or clicking the button and rotating the camera) there is more up/down view area than left/right view area.

    That sounds kind of cool! Sorry I don't have any suggestion how to implement it.

    Please update when you find a solution.
     
  5. Stv3D

    Stv3D

    Joined:
    Dec 10, 2011
    Posts:
    34
    It could work if you rotate the screen physically. But that is assuming you are building for mobile devices.
    For that you should look at some of the APIs such as the gyroscope.

    http://docs.unity3d.com/ScriptReference/Gyroscope.html

    Although I do not know how hard it will be to implement, Sorry.
     
  6. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Two cameras? One rendering the fixed part of the scene (and don't rotate that camera) and one rendering the parts you want to rotate?

    Use layers and the cameras' culling masks to force certain items render to the correct camera.

    Would that work?
     
  7. Chubysnow

    Chubysnow

    Joined:
    Jul 2, 2013
    Posts:
    5
    TheAnimator2d, that is exactly what I want.

    To me, the best solution seems something similar-ish to what Larku suggested. In theory, I would use two cameras, one taking a small portion of a large game view and rendering it to a texture on a plane, and then a second camera, looking directly at that plane, which would render to the screen. The plane and the camera would be rotated oppositely, allowing the player to view more, without actually rotating the objects in game. However, I was unable to implement this as Render Texture requires Unity Pro and rendering a camera to a texture is too expensive computationally otherwise. I find it hard to believe that this is so difficult to pull off, because rotating a camera in reality does not rotate the objects in your view, it simply rotates your view.
     
  8. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Hey Chubysnow,

    I'm not sure you'd need render texture for this - you'd just use two cameras. You can have two or more cameras all render directly to the screen.

    You'll need to set Clear Flags, Culling Mask and Depth correctly on each camera.

    Also if you use Unity 5 you can have render textures (and all other pro features)
     
  9. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    I think you're confusing things here. It doesn't matter if you rotate the camera or the world, the end result is the same. What you are trying to do here instead is to rotate the viewport (*) - which is not the same as rotating the camera.

    As larku pointed out, Unity 5 Personal Edition also has RenderTextures now, so the provided solution with the plane sounds quite nice to me.

    (*) Which is the same as rotating the device displaying the viewport contents. It's all relative.