Switch camera or change FOV with lua

Discussion in 'Programming' started by Shadow_Clan1965, Jul 1, 2024.

  1. Shadow_Clan1965

    Shadow_Clan1965
    Expand Collapse

    Joined:
    Aug 25, 2018
    Messages:
    103
    Hello, im trying to either change between two cameras or dynamically change the fov. I want to be using custom internal cameras and I have those both in place. But I can't seem to find any way to do either of these things.

    I found this reference but not a way to actually use any of it: https://angelo234.github.io/List-of-BeamNG-Functions-And-Fields/velua.html

    Any help would be appreciated.
     
  2. SineMatic

    SineMatic
    Expand Collapse

    Joined:
    Nov 17, 2022
    Messages:
    68
    Only for free camera:
    Code:
    core_camera.setFOV(angle)
    For all cameras:
    Code:
    -- sample code
    
    onUpdate(dt)
       if core_camera.getFovDeg() < finalFOV then
          core_camera.cameraZoom(direction * zoomSpeed)
          -- direction is 1 or -1
       else
          core_camera.cameraZoom(0)
          -- stop zooming
       end
    end
    
    Instead of calling 'getFovDeg()' method you could try implementing some dt-dependent FoV changer
     
    #2 SineMatic, Jul 29, 2024
    Last edited: Jul 29, 2024
  3. golgo1387

    golgo1387
    Expand Collapse

    Joined:
    Sep 9, 2023
    Messages:
    129
    Can you tell me how to specifically do that?
    I haven't had much luck making LUA mods that work.
    I want to set all car cameras (internal and hood especially) to a certain FOV, like say 65 degrees, and have it 'sticky' there for any car.
    I don't care about the Free Camera.
    Thanks!
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice