Forum rules - please read before posting.

Orthographic camera in 2d games?

edited October 2014 in Technical Q&A
Is there any reason why the main camera has to be a perspective one? I hadn't even noticed that this was the case until I had to change it because I wanted to try mixing some 3d objects in my 2d scene (for a 2d game) and the perspective camera wouldn't cut it, and while things look great with the orthographic camera, sadly when I run the game I now see that camera behaviours don't work anymore (specifically the camera won't pan along with my character).

Any hints/tips/insight? I was going to see if I can "fix" this (i.e. see if I can get the camera to animate again), but I thought I'd check here first to make sure I am not "fixing" something that's actually by design.

Comments

  • sadly when I run the game I now see that camera behaviours don't work anymore (specifically the camera won't pan along with my character).

    I had something similar going on when I set up a new scene, perhaps that's why the main camera wouldn't animate horizontally along with my character. Now, though, it is set to orthographic and it does animate along with the character. I remember fixing it by deleting my MainCamera from the scene and dragging it in anew from Adventure Creator/Prefabs/Automatic/MainCamera.prefab, but I couldn't tell you if that specifically was the solution as I was just desperately trying a bunch of things.
  • Thanks Eastman. I gave up in the end as I was going through AC's camera code and based on what I was seeing there it looked like what I was trying to do probably wouldn't work as AC does some interesting stuff to "animate" orthographic cameras left and right (pan). 

    Based on what you're saying however it sounds like it may be possible, which is is interesting so I may give it another shot when I get the chance.
  • Actually I did give it a quick shot and it did work Eastman so well done once again sir!

    Quite weird as I am pretty sure I had set up my MainCamera in the same way (i.e. using the Game Editor tools). Oh well, maybe I hadn't and I just remember it wrong.

    All that said I am still having a bit of an issue (although unrelated to AC really) as my 3d object now overlaps the character at all times, which is not how I wanted it to work. Makes sense obviously as the 3d object doesn't have a concept of "Order in Layer", but that still doesn't help me! :) Guess I need to get creative!
  • Still struggling quite a lot with orthographic/perspective cameras in AC...

    I am now needing to do a sign that sways in the wind which is not even a 3d object just a 2d sprite and as the sprite animates (rotates on the X) it looks completely wrong in the perspective camera.

    Changing it to an orthographic cam as per eastman's suggestion above does fix the issue, but it breaks the game in the following way:

    I now have an intro cutscene for this scene which basically switches a camera from a start position to an end position over a long period of time (to achieve a pan effect) and then switches to the main game cam when the game starts. To fix the perspective issue I have to make all these cameras orthographic. However when I do, my main game cam doesn't follow the player when the game starts (Target is Player? is definitely set to true). If I deactivate the intro cutscene it works fine. So it's something about the switch that makes this fail.

    I suppose I could try having just the one (main) camera and animating that instead of switching between the different cameras...
  • Found it!

    It was pretty simple in the end.

    My scene constraints for my perspective camera did't work for the orthographic camera (they were tiny, hence no movement from the camera)

    So I had to go in and tweak the constraints again

    I had also prepositioned the main game cam to be where it should be after the fix and I think that was throwing things off too. I put it back to (0,0) and all is good now.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.