Forum rules - please read before posting.

Interrupt Action and Switch back to previous Camera or via Script

Hello,

I am trying to figure out how to achieve this:

CameraX is positioned at a 'activator' location,
Player has his TopDownCam

Player will press ALT+1, then an action or via script I want to switch to CameraX within X seconds.

When the player releases the ALT+1 I revert back to regular camera instantly,

However if the Player releases mid way I want the transition to be interrupted and revert back immediately as well,

Any help with this would  be greatly appreciated,


Thank you

Comments

  • Hello again,

    I was trying to understand the Action script for Switch camera and this is what I got so far:



    Now all I need is a better working system to return to the camera before the buttons were pressed,

    Currently I am at a halt trying to figure that out,

    Also let me know if what I'm doing is not ideal and if there is a better way,

    Thank you

  • If you want to keep the size of the code down, you can have the camera-switching done via regular Camera: Switch Actions and simply run the ActionLists through script by invoking their Interact() methods.

    I'm afraid I don't follow what you mean by "returning to the camera before the buttons were pressed".
  • Sorry for the confusion,

    If the player presses ALT+1 go to TheCam Location, releases go back

    How do I tell the script or the actions what the original camera was to go back to?
  • In script, you'd use what you already are: GetLastGameplayCamera()

    If using Actions, you should just be able to check Return to last gameplay? - no need to explicitly tell it which.

    If you do want to use script to record the last-gameplay camera, just create a reference to MainCamera's attachedCamera before the initial switch, ie.:

    _Camera oldCamera = KickStarter.mainCamera.attachedCamera;
    TransitionToCam(GreenActivatorCam);

    You can then use that later on when switching back.
  • Thanks Chris,

    I was again overthinking it and using the Actions works way better.

    What is the difference between Interact and AdvGame.RunActionListAsset(actionName);

    I have a script called References with public ActionListAssets and voids that call upon whichever named action with RunActionListAsset,


    Also Should I start a new thread or this can be answered here as well?

    I have this Script: GreenActivatorCam = GameObject.Find("GreenActivatorCam").GetComponent<_Camera>();

    However instead I would like to simply reference it by using your magical constant ID, similarly to how your Actions know exactly which one it is, that way I can get rid of the ugly Find script and ensure it is done proper,

    Much appreciated all of your help.


  • Interact is just simpler to write - both are identical.

    To retrieve a component by ConstantID, you use Serializer.returnComponent:

    _Camera myCamera = Serializer.returnComponent <_Camera> (myConstantID);

  • Super powerful,

    I figured out now how to use it for other Objects as well, this makes life easier.

    Are there any limitations for using the constantId's on objects, and performance issues on calling them or?

    Thank you
  • I wouldn't run it every frame or anything.  AC itself generally only calls that either when saving/loading, or when running an Action for the first time.
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.