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. Let us know your feedback about the Global Illumination changes in the 2023.2 beta.
    Dismiss Notice
  3. Dismiss Notice

Getting error when using new FPS Controller

Discussion in 'Unity 5 Pre-order Beta' started by Warrior1424, Dec 11, 2014.

  1. Warrior1424

    Warrior1424

    Joined:
    Sep 30, 2010
    Posts:
    984
    When I import the new FPS Controller from the launch screen when I make a new project and place it in a scene, I get the following error a bunch of times:
    At this line:
    Code (CSharp):
    1.  camera.localRotation = m_CameraTargetRot;
    I don't know if this could be related, but I didn't import the CrossPlatform package, as I don't need it and I would hope packages would function independently of one another.

    I am using Beta 14, but I looked at the change logs for 15 and 16, and didn't see anything that had to do with this.
     
  2. DanSuperGP

    DanSuperGP

    Joined:
    Apr 7, 2013
    Posts:
    408
    Seems like a good candidate for a bug report.
     
  3. Warrior1424

    Warrior1424

    Joined:
    Sep 30, 2010
    Posts:
    984
    Should I use the in-editor bug report tool?
    I had forgotten it was even there.
     
  4. DanSuperGP

    DanSuperGP

    Joined:
    Apr 7, 2013
    Posts:
    408
  5. RoboticDoorstop

    RoboticDoorstop

    Joined:
    Nov 6, 2012
    Posts:
    5
    I just ran into this this morning. It looks like it's never being initialized. Since I didn't want to dig around and find the best place to initialize this, and the "LookRotation" method takes the same parameters as the Init method, I've checked to see if the rotation has already been initialized, if not I initialize it with the current values.

    Code (CSharp):
    1.        
    2.   private bool m_isInitialized = false;
    3.    public void Init(Transform character, Transform camera)
    4.    {
    5.       m_CharacterTargetRot = character.localRotation;
    6.       m_CameraTargetRot = camera.localRotation;
    7.       m_isInitialized = true;
    8.    }
    9.  
    10.    public void LookRotation(Transform character, Transform camera)
    11.    {
    12.       if(!m_isInitialized)
    13.       {
    14.          Init(character, camera);
    15.          return;
    16.       }
    17.       float yRot = CrossPlatformInputManager.GetAxis("Mouse X") * XSensitivity;
    18.  
     
  6. RoboticDoorstop

    RoboticDoorstop

    Joined:
    Nov 6, 2012
    Posts:
    5
    Actually a simpler, and likely more correct, fix would be to add the following to the end of the FirstPersonController's Start method:
    Code (CSharp):
    1. m_MouseLook.Init( m_CharacterController.transform, m_Camera.transform );
     
    gabrielgame999 and brendo like this.