Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Standard FPS camera with Cinemachine

Discussion in 'Cinemachine' started by anseyder, Feb 6, 2018.

  1. anseyder

    anseyder

    Joined:
    Feb 5, 2018
    Posts:
    20
    Hi all

    I have spent ages trying to find this out - so forgive me if the info is out there - I couldn't find it.

    I am creating an FPS training simulation using the standard assets FPS controller. At certain times I want to switch to a different camera and back again when I interact with objects or after a camera dolly etc. driven via script.

    I cannot find a tutorial on how to blend Cinemachine with the standard FPS controller. I currently have a dolly track that goes, and when done switches to the FPS camera (it is set up as an external camera) but the controlls are totally screwed up - notably the mouse rotation is badly offset.

    I am also doing all my interactions with Playmaker - I don't know C#.

    I thought this would be the ideal scenario for cinemachine but I just can't get it to work or find tutorials on how to get it happening - every tutorial I have seen seems to focus on a variety of 3rd person cameras. Does Cinemachine integrate with the standard fps camera/controller?

    thanks in advance
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    1. Make sure the Main Camera in your scene has a CinemachineBrain componenmt (either add one directly, or create then delete a Virtual Camera).
    2. Drop the FPSController prefab into your scene.
    3. In the prefab instance, disable the built-in Camera and add a CinemachineExternalCamera component instead.
    That's it. Now the FPS controller will drive the main Camera via the CinemachineExternalCamera component inside it. Blends, Timeline, etc will all function correctly.
     
    Remi_Tribia, ArchaicJohn and anseyder like this.
  3. anseyder

    anseyder

    Joined:
    Feb 5, 2018
    Posts:
    20
    will give it a crack today - thanks!
     
  4. anseyder

    anseyder

    Joined:
    Feb 5, 2018
    Posts:
    20
    thanks for that - got around to trying it, but the new camera only looks left and right on a fixed plane, I can't look up and down like normal. How do I have the externalcamera work in the same manner as the normal one?

    this is after disabling the FPS camera component, I can look around fine if it is still "ticked" as active.

    cheers
     
  5. anseyder

    anseyder

    Joined:
    Feb 5, 2018
    Posts:
    20
    sorry - figured it out, now just need to work on nice blends :)
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
  7. crawfis

    crawfis

    Joined:
    Jan 30, 2014
    Posts:
    114
    We need a good tutorial on FPS with Cinemachine. I think there is some confusion on the separation of concerns with controller, versus camera behavior. It seems like Cinemachine is concerned with the behavior and very flexible / advanced. What you "attach it" to can be controlled by the user, AI, etc. I guess how you attach it is also flexible: lookat, follow, etc. Trying to find a resource to share with my class.
     
  8. DRCornelius

    DRCornelius

    Joined:
    Oct 31, 2018
    Posts:
    2
    What did you do to figure this out? I tried the link below with the extension script but it didn't seem to work. Having said that I don't know if I need to attach the extension script to anything or where to put it. So I don't know if I am applying the script correctly.
     
  9. IgnacioLlacay

    IgnacioLlacay

    Joined:
    Dec 11, 2018
    Posts:
    3
    This is an old thread, however I encountered the same problem now. For anyone else in this case, I could make it work only when the FPS has the build-in Camera enabled, together with the Cinemachine Virtual Camera component in it (as oposed to what @Gregoryl states, which I also read in the Cinemachine External Camera Unity Manual).

    Also following the Documentation linked above, which states the External Camera Component is now depreciated, I could make it work using the normal CinemachineVirtualCamera with Do Nothing in both Aim and Body in the FirstPersonCharacter in the FPS Controller, only when also having its camera component enabled, same as before. If I disable the camera component in the FPS, the Y axis rotation is disabled again.
     
    FlightOfOne likes this.
  10. DaCrIaX

    DaCrIaX

    Joined:
    Sep 19, 2020
    Posts:
    1
    I've been trying to make this work with the unity new input system, and well, the camera works as intended, however my character controller is moving sideways without paying attention to the camera orientation.
     
  11. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Why don't you change your character controller to make it pay attention to the camera direction? There is some character controller code in the CM samples that you can use for inspiration.