Forum rules - please read before posting.

Camera Switch using class functions

edited October 2015 in Technical Q&A
Hey,

As title says, looking to write a line of code that will switch the camera.

http://www.adventurecreator.org/scripting-guide/class_a_c_1_1___camera.html

Looked into the docs and saw no switch camera, or something simular.

Also, needs to set a variable the same time via code also.

Cheers

Gav

Comments

  • Since the MainCamera is what performs the actual rendering, the code to change camera is located in the MainCamera class.

    The GlobalVariables and LocalVariables classes can be used to read/write global and local variables respectively.
  • edited October 2015
    Hi Chris, thanks for the reply.

    Im still having trouble switching to a second GameCamera2D in my script.

     AC.MainCamera - has no functions found - just like when all functions are private, but looking into the class, they are all public. 

    image



    However, AC.GlobalVariables has all the function listed.

    image


    I have also tried looking at Kickstarter:

    AC.KickStarter.mainCamera.SetGameCamera(cam, 0.0f, MoveMethod.Smooth, null);
    AC.KickStarter.mainCamera.SnapToAttached ();

    no errors, but the camera didn't switch.

    Anyway, hope you can help. It's giving me a headache haha

    Cheers

    Gav
  • GlobalVariables has static functions, but MainCamera does not - that's why you need to refer to the "KickStarter" instance instead.

    Any errors in the console?  Know that you can always just place a "Camera: Switch" Action in a Cutscene and run that Cutscene through script instead - just call it's "Interact" function.
  • Hey,

    Got it working. Same code with kickstarter, but this time works. lol

    To run an interaction through code - how is this achievable ?

    Thanks
  • Same as a Cutscene - it derives from "ActionList" as well, so use the Interact() function.
  • edited October 2015
    Got it :)


    ┈┈┈┈┈┈▕▔╲
    ┈┈┈┈┈┈┈▏▕
    ┈┈┈┈┈┈┈▏▕▂▂▂
    ▂▂▂▂▂▂╱┈▕▂▂▂▏
    ▉▉▉▉▉┈┈┈▕▂▂▂▏
    ▉▉▉▉▉┈┈┈▕▂▂▂▏
    ▔▔▔▔▔▔╲▂▕▂▂▂I
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.