Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question How to get Cinemachine with "Aim" - "POV" forward Vector?

Discussion in 'Cinemachine' started by Cooo_oooper, Sep 24, 2023.

  1. Cooo_oooper

    Cooo_oooper

    Joined:
    Apr 20, 2023
    Posts:
    9
    Hello all,
    I have a virtual camera that is positioned on my player and whose aim HoizontalAxis Value matches the players rotation. The VerticalAxis Value is also controlled by the mouse.
    Now I used a normal Camera before and shoot a Raycast forward from it to dected stuff. But with the virtual camera the forward vector is always to global positive Z and never changes its rotation.

    So how do i get the forward vector of a virtual camera?
     
  2. antoinecharton

    antoinecharton

    Unity Technologies

    Joined:
    Jul 22, 2020
    Posts:
    156
    Heyyo :) ,

    Have you tried using the transform.forward vector of your virtual camera?
     
  3. Cooo_oooper

    Cooo_oooper

    Joined:
    Apr 20, 2023
    Posts:
    9
    Hello,

    sorry for the late reply.
    Yes, I tried using the transform.forward vector of my virtual camera but in the POV mode of the vcam it always stays at (0, 0, 1) even when my true look direction changes. The main camera has the correct forward vector. I think it would make sense if the vcam forward vector were the same as the actual look direction or if there was a method to get it.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,233
    Try vcam.State.FinalOrientation
     
    Cooo_oooper likes this.
  5. Cooo_oooper

    Cooo_oooper

    Joined:
    Apr 20, 2023
    Posts:
    9
    Thanks. That gives me a rotation. Though it doesn't seem to be the same as the rotation of the actual main camera. E.g. When I look straight along positive Z my main camera has the forward vector (0,0,1) but the vcam has (1,0,0).
    Though this seems like something some math can fix somehow.