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

Resolved transform.position assign attempt for 'Camera' is not valid. Input position is { NaN, NaN, NaN }.

Discussion in 'Cinemachine' started by tomworcom, Aug 16, 2023.

  1. tomworcom

    tomworcom

    Joined:
    Dec 27, 2011
    Posts:
    44
    Hi,

    first: I've been using Cinemachine for years now and I'm super happy with it.
    Yesterday I did an overdue updating spree for on my game from Unity 2020 -> 2022 which to my surprise went almost flawlessly. The one thing I can't figure out is a tiny issue with CinemachineVirtualCamera not transitioning properly.

    So I'm using Unity 2022.3.7f1 and Cinemachine 2.9.7

    Virtual Camera Setup / Flow:
    MenuCamera > GameStartCamera > PlayerFollowCamera
    [player dies]
    PlayerFollowCamera > GameOverCamera
    [Play again]
    GameOverCamera > GameStartCamera [!!ERROR!!] > PlayerFollowCamera [!!ERROR!!]

    The error message I get after restarting the game is
    Code (CSharp):
    1.  
    2. transform.position assign attempt for 'Camera' is not valid. Input position is { NaN, NaN, NaN }.
    3.  
    It gets hammered like 200-350 times into the console right after the GameStartCamera is activated and about a second or two into the PlayerFollowCamera being activated, then it just stops.
    The rotation adapts correctly, just the position is stuck. When the error messages stop, the camera jumps into the correct position.
    And on top of this: It sometimes works, approximately 1 out of 5 restarts.

    I checked:
    - Follow and Aim targets are set throughout (though dynamically through OnEnable() on the vcams)
    - No huge positions (-100 -> +100) in transform.position of cameras or aim/follow GameObjects.
    - FOV is the same for all vcams
    - Clipping planes are 0.1 -> 1000 on all vcams

    Would be thankful for any tips on how to solve this.

    Cheers,
    Tom
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,233
    Interesting. Would you be willing to send me the project?
     
  3. tomworcom

    tomworcom

    Joined:
    Dec 27, 2011
    Posts:
    44
    Absolutely. Where/How would I do that?
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,233
    You can zip it up, upload it to a sharing site, and DM me the link. When you zip it up, you only need to include the Assets, Packages, Project Settings, and User Settings directories. The rest can get regenerated by Unity.

    If the zipfile is small enough, you can attach it directly to the message and skip the sharing site.
     
  5. tomworcom

    tomworcom

    Joined:
    Dec 27, 2011
    Posts:
    44
    Just to wrap this up: The issue came from an active CinemachineCollider component without a set target.
    Will also be fixed in upcoming version 2.9.8 of Cinemachine.
    Thanks to @Gregoryl for help with the debugging!
     
    antoinecharton and Gregoryl like this.