What Is Setcontroltargetvalue Used For?

Discussion in 'General Discussion' started by wenxdx, Nov 2, 2025 at 6:53 AM.

  1. wenxdx

    wenxdx New Member

    Joined:
    Sep 1, 2025
    Messages:
    17
    Likes Received:
    0
    Hello everyone, recently I was playing with the DTG-produced model 'DB BR261 - Voith Gravita' and became very interested in its control system. So I managed to take a look at its script and found something like this: 'Call("SetControlTargetValue", "VirtualBrake", 0, 0)'. I would like to ask everyone, what does 'SetControlTargetValue' mean, and what is its function?
     
  2. wenxdx

    wenxdx New Member

    Joined:
    Sep 1, 2025
    Messages:
    17
    Likes Received:
    0
  3. Maik Goltz

    Maik Goltz Well-Known Member

    Joined:
    Dec 9, 2016
    Messages:
    1,164
    Likes Received:
    5,209
    A control has a interpolated movement to a new position when used by input devices like mouse, keyboard or game pad. The input sets a targeted value and the game then moves the control to that targeted value multiplied by the set interaction speed and inter frame time (delta time). When setting a control directly via script with SetControlValue it snaps immediately to the new set position without the interpolation. SetControlTargetValue sets only the targeted value as with the input devices and the game moves the control to that targeted position then by the interpolation.

    From my experiences it works not on all controls, especially not the hard coded ones. But works for most self defined controls.
     
    • Helpful Helpful x 1
  4. 749006

    749006 Well-Known Member

    Joined:
    Dec 10, 2016
    Messages:
    10,583
    Likes Received:
    3,280
    I thought you would have a better explanation of what it does :)
     
    • Like Like x 1
  5. wenxdx

    wenxdx New Member

    Joined:
    Sep 1, 2025
    Messages:
    17
    Likes Received:
    0
    Thank you for your answer
     
  6. wenxdx

    wenxdx New Member

    Joined:
    Sep 1, 2025
    Messages:
    17
    Likes Received:
    0
    btw,I want to make a power handle like it.Can you teach me?
    It means automatically returning to a certain value after the user completes an action (for example, using the control lever in the cockpit, controlling with the keyboard, or dragging the HUD with the mouse), while not locking the user out during the reset process
     
    Last edited: Nov 3, 2025 at 10:21 AM
  7. Oystein

    Oystein Well-Known Member

    Joined:
    May 24, 2018
    Messages:
    340
    Likes Received:
    334
    Doesn't this depend on your frame rate? So if you have very low or high frame rate it will impact the time it takes for the control to reach the target, which isn't optimal. In this case, the brakes will apply/release quicker if you have very high frame rate?
    Can you give some more info about this power handle? This could be done very easily with a virtual control, but it depends on how it works irl.
     
  8. wenxdx

    wenxdx New Member

    Joined:
    Sep 1, 2025
    Messages:
    17
    Likes Received:
    0
    When the power handle is in gear 1, the regulator value is 0. In gear 2, the regulator is 0.1. In gear 3, the regulator value gradually decreases. In gear 4, the regulator remains unchanged(Hold). In gear 5, the regulator gradually increases.When Regulator less then 0.1 and the power handle is in gear 3,the power handle was set to gear 2
     
    Last edited: Nov 3, 2025 at 1:38 PM
  9. wenxdx

    wenxdx New Member

    Joined:
    Sep 1, 2025
    Messages:
    17
    Likes Received:
    0
    thank you very
    thank you very much
     
  10. Maik Goltz

    Maik Goltz Well-Known Member

    Joined:
    Dec 9, 2016
    Messages:
    1,164
    Likes Received:
    5,209
    Right. Some controls are doing that, what is a pain. I have scripted some important levers therefor and bound them to the interframe time in stead of the frame rate. So they act independent from the framerate. But lots of extra work to achieve that and two more controls in the list for each lever you want to "fix".
     
    • Like Like x 1
  11. Oystein

    Oystein Well-Known Member

    Joined:
    May 24, 2018
    Messages:
    340
    Likes Received:
    334
    After using position 3 and 5, does it automatically jump to position 4 (hold)?
     
    • Helpful Helpful x 1
  12. wenxdx

    wenxdx New Member

    Joined:
    Sep 1, 2025
    Messages:
    17
    Likes Received:
    0
     
  13. wenxdx

    wenxdx New Member

    Joined:
    Sep 1, 2025
    Messages:
    17
    Likes Received:
    0
    Oh,I forget to say.It will automatically switch to gear 2 when in gear 3 and the regulator is less than 0.1
     

Share This Page