TheFlashBold / valheim-firstperson

1 stars 0 forks source link

Change FOV in First person. #3

Open C4LLZ opened 3 years ago

C4LLZ commented 3 years ago

Hello! Installed and the mod and looked around in Dnspy but could not figure out how to change FOV in first person. Any chance you could give me directions on how to?

TheFlashBold commented 3 years ago

You cam set the fov in the console of the game. Open with F5 and type "fov ". Or you could patch the LateUpdate function of class GameCamera in assembly_valheim.dll

Replace the keypadEnter if with:

if (Input.GetKeyDown(KeyCode.KeypadEnter))
{
    this.isFirstPerson = !this.isFirstPerson;
    if (this.isFirstPerson)
    {
        this.originalFov = this.m_skyCamera.fieldOfView;
        this.m_skyCamera.fieldOfView = 90f;
        this.m_camera.fieldOfView = 90f;
    }
    else
    {
        this.m_skyCamera.fieldOfView = this.originalFov;
        this.m_camera.fieldOfView = this.originalFov;
    }
}

and add private float originalFov; to the class.

C4LLZ commented 3 years ago

Hmm I tried adding "private float originalFov;" to the class but got this error message. image image

TheFlashBold commented 3 years ago

Edit LateUpdate method and add private float originalFov; next to the method in partial class GameCamera. Then you should be able to compile. For some reason you cant modify the whole class.