Forum rules - please read before posting.

Switching cameras from Playmaker

I am using AC with a First Person camera and at some point, I want to be able to switch cameras using Playmaker.

Switching cameras from within an AC ActionList works fine (using Cameras - Switch), but the Playmaker action "Set Main Camera" doesn't work (probably because of using the first person camera in AC).

I was thinking of creating an AC ActionList with a GameObject parameter and a Cameras-Switch action inside which I could call from Playmaker, but I can't seem to figure out how to pass the GameObject onto AC from PM (when using the Send Message Action, with the ActionList as the GameObject and using the Interact method, if I specify the camera as the Parameter, it doesn't seem to be passed onto the AC ActionList).

As AC has no GameObject type variables, I can't either share a global variable with PM which could contain the camera and then just call the ActionList from PM to switch the camera.

Any ideas on how to go about this? Any way in which PM can pass object parameters back to AC?

Comments

  • You can modify an ActionList's parameter values through script - but not by passing a single parameter into the Interact method.  Instead, you use the GetParameter function to get a parameter by ID number, and set its value using SetValue:

    actionList.GetParameter (0).SetValue (myGameObject);

    Where "0" is the ID of the GameObject parameter, and "myGameObject" is your new value.  Calling this before Interact will set the value when next run.

    However, it should be possible to still have AC's MainCamera disable in favour of the PM one.  What exactly happens when "Set Main Camera" is run?
  • I think the issue is related to my camera configuration in AC, as when I switch cameras using an ActionList, I need to make the engine wait and when it exits, it returns to the First Person Camera.

    So that's probably just what's happening when PM tries to switch cameras (instantly switches back to the First Person Camera).

    I tried disabling the first person camera component from within the ActionList, but this doesn't seem to solve the issue. Any ideas?
  • See the end of the "First person" chapter of the Manual (2.2.3).  The first-person camera will always be used when in gameplay with First Person movement.  But you can change the movement method to "None" using the Engine: Manage systems Action when you want to use another gameplay camera.
  • edited December 2017
    It's interesting, using Engine : Manage Systems and setting movement method to "none" in an ActionList does work for me.

    However, when I stop the game and then restart it, I can't move anymore and the console displays "Starting a non-First Person game with a locked cursor - is this correct?".

    Changing the setting with an Action in the game also changes the setting in the AC game parameters (under "Settings - Interface settings - Movement method"). Surely a change made at runtime shouldn't remain in the settings after the game is stopped?
  • On this topic, is there any way to "mix" the first person and straight to cursor movement methods?

    It would be great to be able to rotate the viewpoint as in "first person" mode, but be able to click the cursor on the floor to move to the player (rather than have to use the arrow keys to move).

    Haven't looked into this yet, but any insights are welcome.
  • Managers are asset files - so changing them at runtime will update the asset and will indeed change their values on startup.

    Any Settings Manager option you want to change during gameplay will need to be set to its default value in its ActionList on start game asset, which is also defined in the Settings Manager.  You can see this noted in the "Movement methods" chapter of the Manual (Section 2.2).

    It would be difficult to "mix" the two movement methods like that - first-person spin rotation works by rotating the player, not the camera - so this would conflict with any movement due to clicking.  You could, however, write a custom first-person camera script that spins itself (not the player's root), and this would be independent of the straight-to-cursor movement (which I'd suspect would be set as the default).

    Custom cameras can be added by adding the "Basic Camera" + Unity Camera components onto an object with your own script.  It will then be visible to your Manager / Action fields.  Since it won't be the AC first-person camera, you'll need to assign it manually during gameplay using the "Camera: Switch" Action.  To attach it as a child object of the Player, which is normally spawned at runtime, you can just leave the player object in the scene file so that you can modify it as necessary.
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.