Solved Force-change player camera?

Discussion in 'Mod Support' started by DuneWulff, Jul 19, 2017.

  1. DuneWulff

    DuneWulff
    Expand Collapse

    Joined:
    Apr 25, 2016
    Messages:
    1,034
    This one is a bit of a mess to understand but I'll try to explain it anyway.

    Essentially, what I'm trying to accomplish is a way to force the current camera mode into "hood view" mode (using triggers or otherwise).

    When the player drives into this "sewer", I'm trying to see if there is a way to force the camera to change from whatever view it is in, to "hood" view. (the sewer sits low so that only small vehicles can drive through it)
    screenshot_00173.png
    If the camera stays the same, it looks like this driving through the sewer (the car is underneath of the pipe.) For obvious reasons this is kinda... ugly.:
    screenshot_00175.png

    I've been trying to mess around with triggers in order to change the camera to the "hood" camera (somewhat similar to how I do "stunt jump" cameras in some of my maps, although those use "observer" cameras) but I imagine doing this probably isn't quite as simple as I imagine it is.
    sewercam.jpg

    Wow, I sure hope this makes sense. ;)
     

    Attached Files:

    • screenshot_00174.png
  2. meywue

    meywue
    Expand Collapse
    Administrator
    BeamNG Team

    Joined:
    Nov 19, 2015
    Messages:
    340
    Hey,

    should be possible with a lua trigger.

    Go to the world editor and create a lua trigger which can be found in the scene tree (Library - Level tab, BeamNG/BeamNGLuaTrigger)



    Place it into your sewer, we will define the actions when you enter and exit the sewer.

    Once the trigger is created, you can define the lua code it's using by clicking on the luaFunction field.



    The code should look like this:

    Code:
    local function myCameraTrigger (data)
        if data.event == "enter" then
          extensions.use('core/camera').setModeByName(0, 'hood')
        else
          extensions.use('core/camera').setModeByName(0, 'orbit')
      end
    end
    
    return myCameraTrigger
    So whenever you enter the trigger, the game will change to hood camera, whenever you exit it, the game will change to orbit camera mode.

    Video - Click to Play - Direct Link
     
    • Like Like x 1
  3. DuneWulff

    DuneWulff
    Expand Collapse

    Joined:
    Apr 25, 2016
    Messages:
    1,034
    Works like a charm! Thanks again, meywue!
     
  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