How to stop hydro from sagging under weight

Discussion in 'Content Creation' started by JacqueNapier, Jul 29, 2023.

  1. JacqueNapier

    JacqueNapier
    Expand Collapse
    Banned

    Joined:
    Jul 28, 2023
    Messages:
    286
    How to stop hydro from sagging under weight ?

    Example.

    Made hydraulic arm for lifting procedure on pick-up truck car carrier bed.

    When there is weight on the bed the hydraulic keeps sagging/bending back to original position.

    It should stop moving after i let my hand off the buttons to move the hydraulic. But it keeps moving or "rubber banding" if there is weight on it.
     
  2. Agent_Y

    Agent_Y
    Expand Collapse
    Jbeam/QA support
    BeamNG Team

    Joined:
    Jul 10, 2020
    Messages:
    10,417
    If it deforms permanently, you have to increase the beamDeform of the hydro. If it springs back into place, you should increase beamSpring. Keep in mind though that with higher beamSpring you might run into instability issues, in that case you will have to increase the weights of the nodes on the hydro ends.
     
  3. JacqueNapier

    JacqueNapier
    Expand Collapse
    Banned

    Joined:
    Jul 28, 2023
    Messages:
    286
    Thank you. However I think in my case I believe I had the wrong input actions.

    Whattya think is the closest input action for KEEP DOING SOMETHING AS LONG AS BUTTON IS HELD ?

    The thing about hydros is the wrong input action and parameters makes it a million dollar event or a zero .
     
  4. Agent_Y

    Agent_Y
    Expand Collapse
    Jbeam/QA support
    BeamNG Team

    Joined:
    Jul 10, 2020
    Messages:
    10,417
    This is not possible to do via input actions alone. You will need a custom_input.lua file and call a function from it with onChange. Examples from the cannon prop:
    input_actions.json:
    Code:
    "liftUp"   :{"order":  3, "onChange":"custom_input.liftBarrel( 0.5 * VALUE)", "title": "ui.inputActions.cannon.liftUp.title", "desc": "ui.inputActions.cannon.liftUp.description" },
    "lowerDown":{"order":  4, "onChange":"custom_input.liftBarrel(-0.5 * VALUE)", "title": "ui.inputActions.cannon.lowerDown.title", "desc": "ui.inputActions.cannon.lowerDown.description" },
    custom_input.lua (in a lua sub-folder of your vehicle folder):
    Code:
    -- This Source Code Form is subject to the terms of the bCDDL, v. 1.1.
    -- If a copy of the bCDDL was not distributed with this
    -- file, You can obtain one at http://beamng.com/bCDDL-1.1.txt
    
    local M = {}
    
    local function onReset()
      electrics.values['lifter'] = 0
      electrics.values['lifter_input'] = 0
    end
    
    local function updateGFX(dt) -- ms
      electrics.values['lifter'] = math.min(1, math.max(-0.0, (electrics.values['lifter'] + electrics.values['lifter_input'] * dt * 0.2)))
    end
    
    local function liftBarrel(value)
      electrics.values.lifter_input = value
    end
    
    -- public interface
    M.onInit    = onReset
    M.onReset   = onReset
    M.updateGFX = updateGFX
    M.liftBarrel = liftBarrel
    
    return M
    the liftBarrel function in this case is the most important one, it sets the electrics value for the lifter input. That value is then converted into your hydro control value in updateGFX. I won't go into detail of what exactly is going on there, this is needed for the lifter to also work on a controller device and not just keyboard.
     
    • Like Like x 1
  5. JacqueNapier

    JacqueNapier
    Expand Collapse
    Banned

    Joined:
    Jul 28, 2023
    Messages:
    286
    Most excellent. Yeah I noticed in your tank creation since you were one of the makers you guys wrote a ton of lua.

    Looks like true functionality involves from us modders that we need to know lua. Blender and knowing what beamspring is is only like 10% LOL.


    BTW the input action is visible in my mod when I copy your liftbarrel example but does not work as the action itself.

    What should by hydro call to action name be ?


    --
    "hydros": [
    ["id1:","id2:"],
    {"beamSpring":"110000000","beamDamp":200}, //25 default
    {"beamDeform":"FLT_MAX","beamStrength":"FLT_MAX"},

    {"beamPrecompression":1.0},
    ["a11", "controlarm31",{"factor":1.0,"inputSource":"liftBarrel","inLimit":0.5,"outLimit":30,"inRate":0.2,"outRate":0.2,"inputFactor":1}],
    ["a8", "controlarm34",{"factor":1.0,"inputSource":"liftBarrel","inLimit":0.5,"outLimit":30,"inRate":0.2,"outRate":0.2,"inputFactor":1}],


    I've tried:
    liftBarrel
    lifter
    lifter_input
    custom_input
    lifeBarrel_input

    What drives me nuts is it appears in vehicle config as a control you can assign buttons but on click it doesn't work.


    Here's my input_actions file

    "controlarm_liftUp": {"order": 5, "onChange":"electrics.values.Controlarm = 1.0* VALUE", "title": "Lift Up CA", "desc": "Lifts controlarm" },
    "controlarm_liftDown": {"order": 6, "onChange":"electrics.values.Controlarm = -1.0* VALUE", "title": "Lift Down CA", "desc": "Lifts controlarm down" },
    "miniarmarm_liftUp": {"order": 7, "onChange":"electrics.values.miniarm = 1.0* VALUE", "title": "Lift Up MA", "desc": "Lifts Miniarm" },
    "miniarmarm_liftDown": {"order": 8, "onChange":"electrics.values.miniarm = -1.0* VALUE", "title": "Lift Down MA", "desc": "Lifts Miniarm down" },
    "controlarm_liftUp2" : {"order": 3, "onChange":"custom_input.liftBarrel( 0.5 * VALUE)", "title": "ui.inputActions.cannon.liftUp.title", "desc": "ui.inputActions.cannon.liftUp.description" },
    "controlarm_lowerDown2": {"order": 4, "onChange":"custom_input.liftBarrel(-0.5 * VALUE)", "title": "ui.inputActions.cannon.lowerDown.title", "desc": "ui.inputActions.cannon.lowerDown.description" },
     
    #5 JacqueNapier, Aug 2, 2023
    Last edited: Aug 2, 2023
  6. Agent_Y

    Agent_Y
    Expand Collapse
    Jbeam/QA support
    BeamNG Team

    Joined:
    Jul 10, 2020
    Messages:
    10,417
    I did not write the lua for the tank, that was there before I worked on it already. The input source should be just lifter. If it's not working then something is wrong with your lua, check the console for errors.
     
    • Like Like x 1
  7. PotatoCubes

    PotatoCubes
    Expand Collapse

    Joined:
    Aug 12, 2018
    Messages:
    21
    How to set a default value for the lifter? Like.. After increasing or decreasing the value I want it to go back to its original position with a push of a button.
     
  8. Richard_Long

    Richard_Long
    Expand Collapse

    Joined:
    Nov 7, 2022
    Messages:
    193
    you shood ask own thread not here. sorry i do nut know how it wqork
     
  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