Search Unity

POV Horizontal and vertical input when world up changes

Discussion in 'Cinemachine' started by vincent_nativo, Mar 12, 2020.

  1. vincent_nativo

    vincent_nativo

    Joined:
    Oct 6, 2019
    Posts:
    13
    Hi,

    Quick question, does the POV aim component in a virtual camera adjust horizontal and vertical input values to make sense against the world up override set on the main camera? I ask because it doesn't appear to and before I keep butting my head against a wall trying different configurations I wanted to see if that basic fundamental is missing.

    My set up is that I have a world override set on the main camera to be a camera anchor object that is a child of the main character. The vcam is set up to be first person in that it the body is "Hard lock to target" and the aim is POV. The follow target is the camera anchor. In the scene, the player can arbitrarily change gravity and be oriented towards a different vector where world up changes from their perspective. Every time I do this, the camera is rotated correctly but the input is wonky, and it seems like the input is still the raw horizontal and vertical input according to real world up and is not adjusted / rotated in any way.

    Of course I could also totally have something set up incorrectly!

    I know that I could probably write a script to manipulate the input x and y values on the POV component to fix this but before I spent time doing that I thought I would pose the question.

    Thanks!
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    The POV does not take the World Up override into account, unfortunately.

    However, I think it is possible to get what you're looking for, because the POV axes are relative to the vcam's parent GameObject. Try making the 1stPerson vcam a child of the anchor object you mention (then you won't need a Follow target or the HardLock in the Body).
     
  3. vincent_nativo

    vincent_nativo

    Joined:
    Oct 6, 2019
    Posts:
    13
    Ah thanks for your very simple solution! Yes, that works as far as the camera orientation and input goes, but it does introduce a new problem for me (rabbit hole). I am also using the Kinematic Character Controller asset which uses the camera orientation to orient the character. So basically, the way the camera is facing drives the forward direction of the character. At the same time the camera is a child of the character (well technically, a child of the camera anchor which is a child of the character) so it is following the character, so you end up going around in circles like a dog chasing it's tail.

    I don't think this is your problem to solve though, I think I need to look at the character controller script and refactor that a little to take the hierarchy change into account. Unless of course you have another quick hack for me :)

    Thanks for your help so far! I'm almost there.
     
    Gregoryl likes this.
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Yes, those feedback loops are not a great idea. I suggest that you take the Camera out of the controller and put it in a separate GameObject. The CM Brain on the Camera will take care of tracking the vcam. It's strongly recommended to have the vcam and the Camera in separate hierarchies.

    So in summary the controller should drive the vcam, not the Camera.
     
  5. vincent_nativo

    vincent_nativo

    Joined:
    Oct 6, 2019
    Posts:
    13
    Sorry, I don't think I was clear. It's the vcam that is the child, not the main camera brain object. Still getting the feedback loop.

    I understand what you're saying about the fact the controller should drive the vcam but I think that when you talk first person it's a bit of a grey area and it's almost like controlling the character becomes a "shared" responsibility between the viewport and the character itself. The direction you're looking with the vcam (so the resulting orientation of the main camera) drives what direction the main character model is facing (it turns in real-time with where you are looking). Giving directional input with the movement keys drives the character position IN THE DIRECTION the character is facing which is being driven by the POV. So you could say that the rotation of the character is driven by the POV while the position of the character is driven by the controller itself.
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    If you're trying to do a pure 1st-person, then maybe you should pull the vcam out of the equation: your mouse could simply control the rotation of the "anchor object", and the direction keys can take its orientation into account. No feedback loop there. Then the vcam can just be a passive child of that, no POV, and there you go.
     
  7. vincent_nativo

    vincent_nativo

    Joined:
    Oct 6, 2019
    Posts:
    13
    Thanks, sounds reasonable, I will try out that approach.

    In case you're wondering I am using cinemachine because I also have a third person vcam that I cut to for certain cutscenes that behaves differently and uses more of the cinemachine functionality. I mention that because I know that strictly speaking, I don't really need to use cinemachine for pure first person and could just use a normal camera.

    Lastly, any chance that POV handling world up properly could be added to the list? This would make it a complete first person solution in my book.
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    I assumed that you had other vcams happening. It makes sense to drive a passive vcam with your controller, because it effectively becomes a custom-logic vcam, that you can blend with other vcams, add noise to, add an Impulse Listener to.

    I don't think POV is the right way to go for 1st person, partly for the reasons that you have discovered. CM 2.6.0 (available in preview) has a new 3rd-person component that is very powerful, and if the camera offset gets set to 0 it can function very well as a 1st-person camera.
     
  9. vincent_nativo

    vincent_nativo

    Joined:
    Oct 6, 2019
    Posts:
    13
    Great news re CM 2.6.0, thanks for the info. Do you happen to know when official release might be, if it's close then it might not be worth the effort for me to do the custom controller.
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    It's scheduled to coincide with 2020.1. Why not give it a spin right now? Look at the 3rdPersonDeadCenterAim sample scene. It follows the paradigm of having the mouse/kybd rotate/move the player, while the camera just tracks that.

    You'd still have to write the controller to move/rotate the player.
     
  11. vincent_nativo

    vincent_nativo

    Joined:
    Oct 6, 2019
    Posts:
    13
    Shall do! Yep, I understand I still need to integrate it with the KCC controller asset.