Search Unity

How to config Cinemachine on a FPS

Discussion in 'Cinemachine' started by churi24, Jul 24, 2017.

  1. churi24

    churi24

    Joined:
    Sep 17, 2013
    Posts:
    98
    How should I configure the virtual camera on Cinemachine for a First Person? o_O
    If you have a better way to do this, just post it ! I'm sure that the Cinemachine team has his own and better way to do this, so please guys, share the how to.:D:D

    This is how I did it...

    I modified the Start of FirstPersonController.cs
    Code (CSharp):
    1.      
    2. // Use this for initialization
    3.         private void Start()
    4.         {
    5.             m_CharacterController = GetComponent<CharacterController>();
    6.             m_Camera = GameObject.Find("POV");
    7.             m_OriginalCameraPosition = m_Camera.transform.localPosition;
    8.             //m_FovKick.Setup(m_Camera);
    9.             //m_HeadBob.Setup(m_Camera, m_StepInterval);
    10.             m_StepCycle = 0f;
    11.             m_NextStep = m_StepCycle/2f;
    12.             m_Jumping = false;
    13.             m_AudioSource = GetComponent<AudioSource>();
    14.             m_MouseLook.Init(transform , m_Camera.transform);
    15.         }

     
    Last edited: Jul 27, 2017
  2. Adam_Myhill

    Adam_Myhill

    Joined:
    Dec 22, 2016
    Posts:
    342
    Hi @churi24 It looks like you're off to a good start RE 1st person shooter. It's a big topic with a lot of questions, so I'll do a little brain dump on ideas and learnings I've had working in this area.

    Don't make a giant ball of code camera which tries to do everything. Instead use a number of virutal cameras for each different scenario. One for the main 1st person shooter. One for when you sprint (maybe widen the FOV) one for when you go to a scope view (then you have blend controls between them) etc.

    Is your gun shooting from the center of the camera's Z axis or from the weapon? That makes a difference as when you get to walls sometimes the gun and your eye 'see' different things

    How are you planning to handle camera shakes on explosions / impacts? There's a few ways to do that. We want to simplify shakes with a new upcoming 'Impulse' module which we're currently developing (no ETA yet, I'm afraid)

    Let us know how it goes and what kinds of goals and issues you're having so we can give specific help
     
  3. churi24

    churi24

    Joined:
    Sep 17, 2013
    Posts:
    98
    I'm a little lost, that's why I had created this post.:D
    The camera mechanic of our game is similar to Outlast, RE7, etc. All the interaction occurs from the center of the camera's Z axis.

    1) The main problem I found here is how to integrate and set up the virtual camera in the head of the character without writing tones of code. We wanna do something similar to Outlast where the player can see his own body.


    So the camera should be in the head of the player and controlled by Input.mouse, I think..

    2) The problem when you are moving. This is a video of our game (without Cinemachine), I have been coding some stuffs for a basic camera, but with Cinemachine I want to delete all the scripts and replace them by Virtual Cameras.

    In my example when you go from Idle to Walk and from Walk to Run, the camara don't smooth between animations, so you can notice how it change between states and that sucks.
    If I integrate virtual cameras to this, the problem is that I don't know how to solve the walking, idle and running moves on the virtual camera without coding. The perlin noise is not realistic for a walk or run, or maybe it's because I don't know how to configure it.. I think it's better for earthquakes, or when you go inside a car, or something similar to that.

    3) A problem to resolve with Virtual Cameras is the smooth of the movement.

    Here in this video the player rotate looking at a tree all the time trying to mantain the tree centered on the camera and moving with W & D while he is running. You can see how the camera shake as if he has a problem with the fps. If I attach the virtual camera to the head of the player I will have this problem, so the virtual camera should follow the player in a smooth way

    In conclusion I have this problems:
    A) How should I integrate and set up the virtual camera,
    B) How do I solve the problem of idle, walk and run moves.
     
    Last edited: Jul 27, 2017
  4. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
    3) Have you tried using different update modes? (Cinemachine Brain)
     
  5. churi24

    churi24

    Joined:
    Sep 17, 2013
    Posts:
    98
    The last video was recorded using Smart Update. If I use Fixed Update or Late Update works much better, but the shaking still exist, it's really tiny but exist. I think I made something wrong with the config of the CM.
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Camera judder in Unity is very often the result of inconsistent FPS for the moving camera and/or subject. A good way to get an impossibly shaky camera is to mix animation modes: move some things with physics (in FixedUpdate), and others in normal Update. Don't do that. Try animating everything in FixedUpdate, and see if the judder goes away.
     
  7. churi24

    churi24

    Joined:
    Sep 17, 2013
    Posts:
    98
    I made some changes.. Now I have the camera perfect without judder . I'm testing everything on a clean scene, just a terrain, some trees, the FirstPersonController and Cinemachine.
    I'm testing some ideas and I have merged the Update inside the FixedUpdate in the FirstPersonController. Now it goes smooth like a silk and the problem is solved. The new question is, why it's working now? o_O
     
    Last edited: Jul 27, 2017
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    It works because Unity guarantees a constant deltaTime in FixedUpdate, but not in Unpdate. Simulations and other things that are sensitive to frame spacing (Cinemachine included) often work better in FixedUpdate.
     
    Alverik and churi24 like this.
  9. churi24

    churi24

    Joined:
    Sep 17, 2013
    Posts:
    98
    Ok, so in that case I only have code to move the character. The camara will follow the character using Cinemachine. So in my case the integration of the virtual camera could be solved right now, but I want to hear more options. Now the main problem is How do I solve the problem of idle, walk and run moves with cinemachine?
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Have a look at CinemachineStateDrivenCamera. It's a kind of manager-meta-camera that gives you an interface to map its vcam children to specific animation states within your character. Make Idle, Walk, and Run vcam children. Set them up the way you like. Then map them to the Idle, Walk, and Run animation states of your character using the interface in the SDC's inspector. The SDC will take care of enabling the right camera at the right time. You can even set up custom blend styles for the transitions. It's incredibly powerful, and no code is needed.
     
    cadeado and Alverik like this.
  11. churi24

    churi24

    Joined:
    Sep 17, 2013
    Posts:
    98
    Yes you are right, but this is the second part, first I need to know how to set up the virtual camera for each state. Perlin Noise for a Walk movement is not a realistic solution unless you know how to config perlin noise for a walk.

    I could make a script with a curve to simulate the movement on each state, but this comment prevents me to go on that way...
    The question here is how do I config the movement on the virtual camera for idle, walk and run ?
     
  12. sebsmax

    sebsmax

    Joined:
    Sep 8, 2015
    Posts:
    118
    Have a look at "Assets\Cinemachine\Examples\Presets" it will change your mind about it!
     
    Gregoryl likes this.
  13. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    CM examples folder includes some perlin noise presets (e.g. handheld, etc). Try playing with those. Adjust the gain and frequency until it approximates what you want. Then fine-tune the profiles later.

    If all else fails, it's always possible to write a custom noise component for Cinemachine (remember, it's modular so this is easy - have a look at CinemachineBasicMultiChannelPerlin.cs - it's really tiny) that can read any noise data you like and apply it. The Multi-Channel-Perlin is just an example of what you can do.
     
  14. churi24

    churi24

    Joined:
    Sep 17, 2013
    Posts:
    98
    Thanks to both, I modified Handheld_normal_mild preset for the idle and works pretty well. But the movements I was trying to do are a quite symmetrical, like a sine.
    I will write some code for this states on CinemachineBasicMultiChannelPerlin.cs but this should be resolved on Cinemachine. I made these questions because this is one of the problems I found on Cinemachine. For these cases we need more settings. Perlin Noise is an option for an irregular terrain like a mountain, but if you are walking over a plane terrain, I need another kind of settings

    From 0:00 to 0:15 (running).
     
    Last edited: Jul 28, 2017
  15. sebsmax

    sebsmax

    Joined:
    Sep 8, 2015
    Posts:
    118
    https://forum.unity3d.com/threads/individual-blend.485247/
    You can directly lower the amount of noise like that:

    Code (CSharp):
    1.  
    2.            freecam.GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>().m_AmplitudeGain = shakeIntensity;
     
  16. churi24

    churi24

    Joined:
    Sep 17, 2013
    Posts:
    98
    Lowering the intensity does not change the way it is done. Also when the character runs, the camera movement is violent and quite symmetric, ergo, we need intensity. (perlin noise is not symmetric at all)
     
  17. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Yes I understand what you need. It's a question of adding a non-random low-frequency signal to the noise, to simulate footsteps. It's really quite easy to do yourself (even though you suggest that Cinemachine should provide it out-of-the-box). You can start by making a custom noise component. Copy CinemachineBasicMultiChannelPerlin.cs. Rename the copy to CustomNoise.cs (or something like that), and just add another channel to it that can hold your signal. You will find that the new component will magically appear in the vcam's inspector, under the "Noise" section.
     
    Adam_Myhill likes this.
  18. churi24

    churi24

    Joined:
    Sep 17, 2013
    Posts:
    98
    The Magical Interfaces! :D
    Code (CSharp):
    1.         public CameraState MutateCameraState(CameraState curState, CameraState statePrevFrame, float deltaTime)
    2.         {
    3.             CameraState newState = curState;
    4.             newState.PositionCorrection = GetNoisePosition();
    5.             newState.OrientationCorrection = GetNoiseRotation();
    6.             return newState;
    7.         }
    8.  
    9.         Vector3 GetNoisePosition()
    10.         {
    11.             float posTargetX = Mathf.Sin(Time.time * walkPositionSpeed.x) * walkPositionAmounts.x;
    12.             float posTargetY = Mathf.Sin(Time.time * walkPositionSpeed.y) * walkPositionAmounts.y;
    13.             float posTargetZ = Mathf.Sin(Time.time * walkPositionSpeed.z) * walkPositionAmounts.z;
    14.             return new Vector3(posTargetX, posTargetY, posTargetZ);
    15.         }
    16.  
    17.         Quaternion GetNoiseRotation()
    18.         {
    19.             float eulTargetX = Mathf.Sin(Time.time * WalkRotationSpeed.x) * walkRotationAmount.x;
    20.             float eulTargetY = Mathf.Sin(Time.time * WalkRotationSpeed.y) * walkRotationAmount.y;
    21.             float eulTargetZ = Mathf.Sin(Time.time * WalkRotationSpeed.z) * walkRotationAmount.z;
    22.             return Quaternion.Euler(eulTargetX, eulTargetY, eulTargetZ);
    23.         }

    The point of this was to mark something that may be useful for cinemachine users. Obviously I do not pretend that cinemachine covers all the gaps in the development of any game because that is impossible, but this seemed useful, at least on fps.
    Ok, now we have a virtual camera following the player, smooth and with the simulation of footsteps.

    I have another question and, as the others, the solution could come from one thousand different forms. how could I solve this? Take a look to the minute 1:54

    I wanna do something similar on the FPS. For example, I have a wall, on the top of the wall there is a message I want the player read when he is walking distracted over there. The camera must look at this point smoothly. I could make a transform.LookAt but I wondering if cinemachine could do that on other way. Any idea?
     
    Last edited: Aug 8, 2017
  19. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    I would do it this way: Set up a second vcam, targeted at the wall message. When it is time to smoothly look at that target, enable (or increase the priority of) that vcam, and CM will smoothly blend from the normal vcam, and back again when you disable it.
     
    Alverik likes this.
  20. churi24

    churi24

    Joined:
    Sep 17, 2013
    Posts:
    98
    Do you think is it a good idea to use Timeline and CM together in this kind of situations? maybe I have to move and rotate the player to look at the interest point, because in our case the player can look his own body.. or maybe I'm making it too complicated and with only the camera move I've got the effect I want.
     
  21. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Timeline and CM together are a very good way to do this. The "look at message" would be like a mini cut-scene. Timeline/CM can be used to blend smoothly between fully user-controlled cameras and baked (or partially-user-controlled) cameras.
     
  22. Go3k

    Go3k

    Joined:
    Oct 21, 2015
    Posts:
    17
    @Adam_Myhill I have the same question, how to config cinemachine on a fps game? is there a recommend solution? I really want to use cinemachine in my fps game, it's awesome.

    By the way @churi24 Thanks for your solution, a good inspiration to me.
     
  23. Adam_Myhill

    Adam_Myhill

    Joined:
    Dec 22, 2016
    Posts:
    342
    @Go3k we are working on a FPS camera type. It probably won't make the CM v2.1 release (next week) but we will get a beta out as soon as possible so people can try it and give us feedback
     
    Corvwyn likes this.
  24. rneron1

    rneron1

    Joined:
    Jun 16, 2017
    Posts:
    9
    Hey Adam, let me know if you need beta test, cause we are investigating to use Cinemachine camera for our game
    Thanks ;)
     
  25. Adam_Myhill

    Adam_Myhill

    Joined:
    Dec 22, 2016
    Posts:
    342
    @rneron1 We'd love your feedback. Fee free to reach out with any questions or camera design desires you may have. We know our documentation isn't amazing (it's gotten a lot better recently though) and the tutorials and demo scenes are minimal (more coming, really, we've hired people) so if we can help with suggesting configurations, we'd love to.

    The POV camera module is currently going through testing. It's going to make our official CM v2.1 release and we'll share in here on the forums for you when it's had a little more testing.
     
  26. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    324
    Hi! Just jumping into Cinemachine today, seeing how I can replace a bulky and messy camera script with this cool stuff. I'm currently using a camera shaker script that resides on a parent object of multiple cameras. That won't really work here, so I'm wondering if the Impulse (and other) modules are out yet, or coming soon?

    Thanks!
     
  27. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    @mgeorgedeveloper No ETA on Impulse yet, I'm afraid. However, it's very easy to make an extension module to Cinemachine for camera shakes etc. There's a convenient hook in the pipeline that allows you to perturb the output of the virtual cameras. It's perfect for camera shakes.

    CinemachineConfiner is implemented using this API, so you can use it as an example and jumping-off point. Make a copy of it, and modify the copy to channel the noise from your existing shaker script to the PositionCorrection and OrientationCorrections channels in CameraState. It's quite straightforward. Because of inheritance, your new extension will appear in the vcam's extension menu.
     
    mgeorgedeveloper likes this.
  28. churi24

    churi24

    Joined:
    Sep 17, 2013
    Posts:
    98
    Hi, we are advancing in the game and cinemachine & timeline were really useful, they helped me to reduce development time (only one developer and one artist on an horror survival project). Soon I will upload a demo showing how Project Nightmares is going. https://www.instagram.com/projectnightmares/

    I have a question .. I have a virtual camera looking at an object that is moving forward with an animation. I'm using "look at" for the virtual camera to follow that target. I want the player to have some control in the camera, that is, always focus on the object, but can move the camera slightly up and to the sides. Any idea how to do this?o_O

    To handle the shake I've made a simple script in 2 minutes, I don't know if this is elegant and correct but it works :p..
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Cinemachine;
    5.  
    6. public class VirtualCameraShaker : MonoBehaviour
    7. {
    8.     public CinemachineVirtualCamera vcam;
    9.     public AnimationCurve curveShake;
    10.     public float shakeTime = 1f;
    11.     private CinemachineBasicMultiChannelPerlin noise;
    12.  
    13.     private void OnEnable()
    14.     {
    15.         noise = vcam.GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>();
    16.         StartCoroutine(ShakeItBaby());
    17.     }
    18.  
    19.     IEnumerator ShakeItBaby()
    20.     {
    21.         float timer = 0f;
    22.         while (timer < shakeTime)
    23.         {
    24.             timer += Time.deltaTime;
    25.             noise.m_AmplitudeGain = curveShake.Evaluate(timer);
    26.             yield return null;
    27.         }
    28.     }
    29. }
     
  29. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    @churi24 Your script looks fine. The only limitation is that using that method you can't have ordinary camera noise (e.g. handheld) at the same time.

    For your question, I would attack it by making a custom Extension, as I described in my previous post. Simply add a user-driven value to the CameraState's OrientationCorrection channel. This rotation will be added to the vcam-generated camera rotation. Voila!
     
  30. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    324
    @Gregoryl worth mentioning - the CinemachineConfiner class you recommend as a starting point, is only included in 2.1RC and not 2.0 from the Asset Store.
     
    Gregoryl likes this.
  31. cfree

    cfree

    Joined:
    Sep 30, 2014
    Posts:
    72
    Hi @Adam_Myhill!!
    You mentioned a FPS Camera Type in Cinemachine... it is released already?
    Thanks!
     
  32. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
    Go to your vCam and change Aim to POV.
     
    SalchipapasGames likes this.
  33. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
  34. discofhc

    discofhc

    Joined:
    Dec 18, 2017
    Posts:
    47
    Guys, little question, please: there are plans to make Cinemachine built-in with Unity? It would be very good :)
     
  35. cfree

    cfree

    Joined:
    Sep 30, 2014
    Posts:
    72
  36. Adam_Myhill

    Adam_Myhill

    Joined:
    Dec 22, 2016
    Posts:
    342
    @discofhc - CM will be 'built into' Unity with the new Package Manager system. Many modules are moving to this Package Manager so the core of Unity becomes smaller and people load up the packages which they want for any given project. We got you!
     
    JakubSmaga, cfree and scvnathan like this.
  37. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
    Hi Adam! Is there any release date/time? (Week/Month)
     
  38. cfree

    cfree

    Joined:
    Sep 30, 2014
    Posts:
    72
    Good to hear!
    I can´t find any official info about the Package Manager (how it will behave)... can you please share any link / info?
    Thanks!
     
  39. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
    cfree likes this.
  40. AAK_Lebanon

    AAK_Lebanon

    Joined:
    May 30, 2015
    Posts:
    77
    Hi there. I created an aiming camera module and I want to share it with you. this will simply rotate with the player, however it allow you to look vertically by a specified amount. it is an updated version of the POV module. I use it with a Transpose module (where I set the Yaw Damping to 1.5). I love it, it work like the camera used in Tombraider when Lara is aiming (or like GTA). hope anyone enjoy it. I like Cinemachine, it is fantastic !

    Code (CSharp):
    1. using UnityEngine;
    2. using Cinemachine;
    3.  
    4. [DocumentationSorting(23, DocumentationSortingAttribute.Level.UserRef)]
    5. [AddComponentMenu("")] // Don't display in add component menu
    6. [RequireComponent(typeof(CinemachinePipeline))]
    7. [SaveDuringPlay]
    8. /// This will allow the virtual camera to rotate with the player horizontaly and to let you set how much it will rotate vertically. very powereful for player aiming scenario
    9. public class PlayerAiming : CinemachineComponentBase
    10. {
    11.     /// <summary>The Vertical axis.  Value is -45..45 (adjustable). Controls the vertical orientation</summary>
    12.     [Tooltip("The Vertical axis.  Value is -45..45 (adjustable). Controls the vertical orientation")]
    13.     public AxisState m_VerticalAxis = new AxisState(300f, 0.1f, 0.1f, 0f, "Mouse Y", true);
    14.  
    15.     public float minVerticalValue = -45;
    16.     public float maxVerticalValue = 45;
    17.  
    18.     private void OnEnable()
    19.     {
    20.         m_VerticalAxis.SetThresholds(minVerticalValue, maxVerticalValue, false);
    21.     }
    22.  
    23.     /// <summary>True if component is enabled and has a LookAt defined</summary>
    24.     public override bool IsValid { get { return enabled; } }
    25.  
    26.     /// <summary>Get the Cinemachine Pipeline stage that this component implements.
    27.     /// Always returns the Aim stage</summary>
    28.     public override CinemachineCore.Stage Stage { get { return CinemachineCore.Stage.Aim; } }
    29.  
    30.     /// <summary>Applies the axis values and orients the camera accordingly</summary>
    31.     /// <param name="curState">The current camera state</param>
    32.     /// <param name="deltaTime">Used for calculating damping.  Not used.</param>
    33.     public override void MutateCameraState(ref CameraState curState, float deltaTime)
    34.     {
    35.         if (!IsValid)
    36.             return;
    37.  
    38.         //UnityEngine.Profiling.Profiler.BeginSample("CinemachinePOV.MutateCameraState");
    39.  
    40.         // Only read joystick when game is playing
    41.         if (deltaTime >= 0 || CinemachineCore.Instance.IsLive(VirtualCamera))
    42.         {
    43.             m_VerticalAxis.Update(deltaTime);
    44.         }
    45.  
    46.         Quaternion rot = FollowTarget.rotation * Quaternion.Euler(m_VerticalAxis.Value, 0, 0);
    47.         rot = rot * Quaternion.FromToRotation(Vector3.up, curState.ReferenceUp);
    48.         curState.OrientationCorrection = curState.OrientationCorrection * rot;
    49.  
    50.         //UnityEngine.Profiling.Profiler.EndSample();
    51.     }
    52. }
     
    ferverence and Gregoryl like this.
  41. AAK_Lebanon

    AAK_Lebanon

    Joined:
    May 30, 2015
    Posts:
    77
    and this is my rig


    upload_2018-2-15_14-14-22.png
    upload_2018-2-15_14-15-7.png

    I set the Follow and LookAt targets at run time (because my game is a Network game ) so I wait when the local player is spwaned...
     

    Attached Files:

  42. AAK_Lebanon

    AAK_Lebanon

    Joined:
    May 30, 2015
    Posts:
    77
  43. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    @AAK_Lebanon Thanks for that contribution! I hope others will find it useful too.
     
    AAK_Lebanon likes this.
  44. peruwiadomo

    peruwiadomo

    Joined:
    Jan 27, 2016
    Posts:
    14
    Hi all quick question about state driven camera and POV component. So I have modified FPS script couples cameras as a child of SDC and I'm trying to get value from horizontal axis but I'm getting null reference.

    Code (CSharp):
    1. transform.localRotation = Quaternion.Euler(0, vCamera.ChildCameras[0].GetComponent<CinemachinePOV>().m_HorizontalAxis.Value, 0);
    Thanks
     
  45. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Break down the line into smaller pieces to identify where the null is coming from
     
  46. peruwiadomo

    peruwiadomo

    Joined:
    Jan 27, 2016
    Posts:
    14
    If I break it down like that

    Code (CSharp):
    1. CinemachinePOV pov = vCamera.ChildCameras[0].GetComponent<CinemachinePOV>();
    2. Debug.Log(pov.name);
    null its on the pov object
     
    Last edited: Sep 26, 2018
  47. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Oh wait, I see it. Use GetCinemachineComponent<>() instead of GetComponent<>().
     
  48. peruwiadomo

    peruwiadomo

    Joined:
    Jan 27, 2016
    Posts:
    14
    It's says that CinemachineCameraBase don't have a definition for GetCinemachineComponent
     
  49. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Yes, you have to cast it to CinemachineVirtualCamera.
    Code (CSharp):
    1. var child = vCamera.ChildCameras[0] as CinemachineVirtualCamera;
    2. if (child != null)
    3. {
    4.     CinemachinePOV pov = child.GetCinemachineComponent<CinemachinePOV>();
    5.     if (pov != null)
    6.     {
    7.         etc
    8.     }
    9. }
    10.  
     
    twitchfactor and peruwiadomo like this.
  50. peruwiadomo

    peruwiadomo

    Joined:
    Jan 27, 2016
    Posts:
    14
    Thank you, its working now.
     
    Gregoryl likes this.