Forum rules - please read before posting.

Look back Camera and Free look?


I'm trying to figure out how to get these 2 to work:

1. When the player presses R to have the camera look backwards (-180degrees), to see what is coming behind the player.

2. When the player is holding "left alt", even though the player might be walking/running, to allow free look around with the camera with the mouse until left alt is released then it goes back to normal,

My current camera settings are:

Spin rotation locked, and always behind target checked on
Pitch rotation locked and fixed angle of 10

Thank you


  • What I've done for the Look back camera is have a 2nd camera with 180 rotation offset,
    I have PlayMaker detecting R key down and then setting a global bool to true "lookBack", running an action asset to check book if true switch to look back,
    then when R is up, it sets bool to false and runs the action again checks and if false sets the camera back to the other one,

    Is this a good way to achieve this?
  • If it works, it works.  You might need a script if you want to avoid it working during cutscenes though.

    Free-looking can be disabled via the Player: Constrain Action or via script.  You could either use PM to run this as with #1, or do it with:

  • Sorry to bother you again, I am trying to use your script to make this work,

    My current active camera is locked for spin and pitch, I tested it with the script and the player cannot look around,

    Then I changed the camera settings to free, whether I hold down FreeAim linked key or not it still does not lock/unlock the looking around it remains to what it is,

    Could you please clarify to me how to achieve this properly?
  • What's the initial state, that you can free-aim, or is the cursor locked?

    Is Lock cursor in screen's centre when game begins? checked in the Settings Manager?
  • The initial state is not as free aim, the cursor was locked and only shown when paused, also it was not " Lock cursor in screen's centre when game begins?"

    However I changed all those settings to test

    So I enabled the lock on center, then had to Setup Input: CursorHorizontal and CursorVertical, was not sure what to put them as to map them on the mouse? so I just put them in as T, G, Y, and H on the keyboad.

    Then testing again, still could not FreeAim,

    I am using Direct Mouse & Keyboard, tank controls

  • edited May 2018
    For use with the mouse, CursorHorizontal and CursorVertical should be defined the same as the default "Mouse X" and "Mouse Y" inputs.

    You also need to set your Movement method to First Person to make use of free-aiming - since that is a first-person camera behaviour.  Otherwise, you will need to write a custom script that handles the camera movement.

    While you get free-aiming to work, remove the custom script for the moment so that it doesn't interfere.
  • Ah I see,

    Thanks Chris. I got all that working,

    However Perhaps what I am trying to achieve is a bit more complex than I thought,

    The way I imagined it is retaining my current Top Down camera, then when the player pushes the "free look" button, that very camera can look around without moving the character (unless the player is moving via its controls) with the direct movement settings,
    then when the player lets go of the Free Look button the camera resets to its locked rotation, pitch etc.

    The effect I am attempting to achieve is that the player can look around without impacting the players movements as an example, player is running forward presses the Free Look button looks left/right/up/down while continuing to run forward.
  • This is the first you've said of it being a top-down camera.  Apologies - from the wording in your original post, I was under the impression this was a first-person issue.  Posting screenshots to illustrate your scenario would help a lot to understand exactly what's going on.

    You could potentially switch to a new GameCamera that has "Follow cursor?" checked when the button is pressed (and switch back after), but the behaviour of a camera's own behaviour changing on a keypress is not AC does.  For complete control over a camera's behaviour, it may be best to have the whole camera be a custom script, which can be added on quite easily (see the "Custom cameras" Manual chapter).

    You could parent such a Camera to an existing GameCamera so that it's position still follows that camera's control, with your own camera script just handling rotation.
  • edited May 2018
    Yes I will be more specific going forward sorry I get caught up in what I'm working on and forget the rest of the world and its differences,

    I think I'm overseeing the power of your 3rd person camera,

    I just noticed that there is an option for Input Axis and I changed it to the Mouse ones we setup earlier, and this actually made perfect sense to me finally (I was very confused using the same walking controls as the camera rot/pitch),

    Now it actually works great and saves a lot of work for any custom scripts when you already have created such amazing ones, especially since I do not have that talent,

    What I need help with to achieve this by script is:

            if (Input.GetButtonDown ("FreeAim"))
              // old code  KickStarter.playerInput.SetFreeAimLock (false);
                // set the current active camera to Limited Pitch / Spin
    else if (Input.GetButtonUp ("FreeAim"))
    // locked

    To call upon your current active camera via script and set it to Limited when FreeAim is down and then set back to locked when not.

    Sorry for any confusion, I will have all the details upfront going forward when help is needed

  • edited May 2018
    Thank you, that's appreciated.

    The Scripting Guide details all public variables and functions that can be manipulated / invoked via custom script.  In the case of the third-person camera's spin and pitch rotation locks, their entries are here:


    You can amend these by exposing a variable reference to your camera, and assigning it in the Inspector:

  • Thanks Chris,

    Quick help needed on this one, how do I always attach / get the current Active Game Camera?

    As sometimes the player may be looking backwards etc, so I want to ensure the spin/pitch Locks enabled on the current active one rather than the one I attach

    From the scripting Guide it looks like
    However I think that is not the active game camera?

  • No, it's:


    However, since you need to access properties of the GameCameraThirdPerson (which is a subclass), you'll also need to cast it:

    GameCameraThirdPerson tpCam = KickStrter.mainCamera.attachedGamera as GameCameraThirdPerson;

  • Thank you kindly,

    Since it is just me working on my game release, I promise to credit where it is due especially with your asset and the phenomenal support you provide throughout.

  • Hi Chris,

    Running into a coding problem as I've no idea how to achieve it.

    I need to extend the script, currently I have 

    in Update
    if (Input.GetButtonDown ("FreeAim"))
                thirdPersonCamera = KickStarter.mainCamera.attachedCamera as GameCameraThirdPerson;
                thirdPersonCamera.spinLock = RotationLock.Free;

    However, I need to first check to ensure the attached Camera is a thirdPerson one, and if not to simply not do anything.

    Otherwise i get errors in the console,

    if you can kindly help me out with that one.

  • You should just be able to do a null check on the thirdPersonCamera:

    if (thirdPersonCamera != null)
      thidPersonCamera.spinLock = RotationLock.Free;
  • edited May 2018
    Ah, so simple.

    Could you also tell me how can I check if a trigger is playing an action, that way I can also disable that option and for a cutscene,

    Thanks for such lightning speed responses.
  • Sorry, in what context?  You mean an Action specifically, or if the Trigger itself is running?

    Might be easier to set a boolean Variable to True while you want something to be disabled, and then read that variable's value.
  • You can check if the game is in "gameplay" mode with:

    AC.KickStarter.stateHandler.IsInGameplay ()

    See the "Custom scripting" chapter of the Manual for more.
  • The trigger runs an action, and normally the action then will either do certain things or run a dialogue speech, sometimes I have a camera switch action,
    in that time I'd like to disable this,

    Still go via variable? I was hoping for a mass control each time there is an action played, dialogue or cutscene

  • Just seen your other response,

    Thank you I will try to work with that.
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.