Forum rules - please read before posting.

[2D] 2D Toolkit cameras

edited March 2014 in Technical Q&A
Hi again Chris,

As far as I can tell 2d camera prefabs used by AC are based off normal Unity 2D cams. Is it feasible to swap them for 2D Toolkit cameras? I'd like to take advantage of their properties, but so far it has not worked for me.

thanks!

Comments

  • You'd have to change the MainCamera, rather than the GameCameras.  The GameCameras are there for reference - the MainCamera copies their position, FOV etc.
  • Sorry, I phrased it in a confusing way - I am operating on a single MainCamera, however swapping it for a tk2d cam with MainCamera script and a Game Camera 2D script results in nothing being displayed. If I loose the 2d game camera script it works, but as much as I want to use 2d toolkit cam properties, I'd also be interested in keeping AC 2D game camera movement control.
  • Is the MainCamera's position and rotation at least correct?  Try adding a Camera component to it, and then disabling it.

    The MainCamera script references it's own Camera component to change the field of view and perspective (it's the latter that allows it to "pan" in 2D)  I don't know if the tk2d camera has these variables exposed or not.  Try modifying the MainCamera script - reference the tk2d component instead of the Camera (look for references to GetComponent <Camera>()).
  • Yes, the position and the rotation of the MainCamera are correct. It's showing what's expected, it just does not move with the character, which is problematic. 2dtk Main Camera seems to be fine with other cam attachments, but it does not seem to be using data provided from them. 

    It does have fov and perspective matrix values exposed (and other std camera values, as a part of CameraSettings field), but the normal operation of GameCamera2D and feeding its values to the MainCamera don't do any good. I've been fiddling with a number of combinations, but nothing worked so far. I've also tried your method, but nothing changed.
  • I tried making this work myself, but 2dTK's camera script is too confusing (smart) for me, and I couldn't get my head around it, I'm afraid.

    For what reason are you trying to make use of the 2dTK camera?  Just so you know: the next update of Adventure Creator involves widescreen support.  (Or more accurately, the ability to force the aspect ratio to whatever you choose)
  • edited March 2014
    Thanks for trying Chris, I hit the wall too and decided to operate on a singular tk2d camera with custom support for some of the original cam functionality in AC for the time being.

    I've decided to adopt 2dTK for a couple of reasons:
    - automatic screen scaling (it sounds like you've got that covered with the aspect ratio control)
    - super efficient sprite packing, especially with dicing (invaluable for a full hd 2d game and for native 2d this feature is only available in pro version, )
    - better managament and control of sprite atlases and sprite animations (this is subjective, but for the time being I feel that especially the latter is superior to Unity's solutions)
    - partial gui support - I do not want to resort to OnGUI and it so happens that 2dtk helps a bit with gui, I could have used dfGUI that I adore, but decided it does not make sense, if I already have a 2d package in place, which can do the trick.




  • Did you ever figure out how to do this? I really would like to get better control on the pixels in the camera. It's very hard to get a perfect 1:1 alignment between the camera and the backgrounds. Unless there is some other trick, using the built in AC mainCamera?
  • Are you having trouble with the 2D Toolkit camera, or with getting the AC MainCamera to copy the exact behaviour of the 2D Toolkit camera?
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.