What Is Setcontroltargetvalue Used For?

Discussion in 'General Discussion' started by wenxdx, Nov 2, 2025.

  1. wenxdx

    wenxdx New Member

    Joined:
    Sep 1, 2025
    Messages:
    25
    Likes Received:
    1
    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:
    25
    Likes Received:
    1
  3. Maik Goltz

    Maik Goltz Well-Known Member

    Joined:
    Dec 9, 2016
    Messages:
    1,167
    Likes Received:
    5,229
    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 2
  4. 749006

    749006 Well-Known Member

    Joined:
    Dec 10, 2016
    Messages:
    10,634
    Likes Received:
    3,317
    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:
    25
    Likes Received:
    1
    Thank you for your answer
     
  6. wenxdx

    wenxdx New Member

    Joined:
    Sep 1, 2025
    Messages:
    25
    Likes Received:
    1
    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
  7. Oystein

    Oystein Well-Known Member

    Joined:
    May 24, 2018
    Messages:
    347
    Likes Received:
    340
    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:
    25
    Likes Received:
    1
    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
  9. wenxdx

    wenxdx New Member

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

    Maik Goltz Well-Known Member

    Joined:
    Dec 9, 2016
    Messages:
    1,167
    Likes Received:
    5,229
    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:
    347
    Likes Received:
    340
    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:
    25
    Likes Received:
    1
     
  13. wenxdx

    wenxdx New Member

    Joined:
    Sep 1, 2025
    Messages:
    25
    Likes Received:
    1
    I try to make a script for this controller
     

    Attached Files:

  14. wenxdx

    wenxdx New Member

    Joined:
    Sep 1, 2025
    Messages:
    25
    Likes Received:
    1
    upload_2025-11-6_23-31-51.png
    when I watch this,I understand all
     
  15. wenxdx

    wenxdx New Member

    Joined:
    Sep 1, 2025
    Messages:
    25
    Likes Received:
    1
    the regulator's max value is 1 but the notch"T+" max value is 1.5.So it can never reach 1.5, it will return to hold when I release the mouse
     
  16. Oystein

    Oystein Well-Known Member

    Joined:
    May 24, 2018
    Messages:
    347
    Likes Received:
    340
    I think you need two controllers/animations for this.

    One controller for position 0, 1 and 2, and a second controller for position 3, 4 and 5.

    Second controller has a minimum value of (just an example) -1, default value of 0 and maximum value of 1. Add irregular notched interface to this, set the first notch to -4, second notch to 0 (default) and third notch to 4. It will never be able to reach notch 1 or 3 since they are out of range of the min/max value for the controller. It will then return to 0. Just like how you have scripted it now.

    The animation for both controllers needs an extra frame, where you move the controller away from the cab/user so that it gets hidden when one of the controllers is in use.

    Let me know if you need more help, I might be able to provide an example.
     
  17. wenxdx

    wenxdx New Member

    Joined:
    Sep 1, 2025
    Messages:
    25
    Likes Received:
    1
    thank you very very much
     
  18. wenxdx

    wenxdx New Member

    Joined:
    Sep 1, 2025
    Messages:
    25
    Likes Received:
    1
    but how to hide the handle1 when the handle2 is used
     
  19. Oystein

    Oystein Well-Known Member

    Joined:
    May 24, 2018
    Messages:
    347
    Likes Received:
    340
    There are two ways, either animate it so that it moves away from the user. Or, use "Interior Visibility Object" under interface elements.
    Lower visibility threshold and Upper Visibility threshold let you specify when the controller(node) is hidden.

    Like in this screenshot, the "tapchanger" node is visible when the value of the controller is between 0.9 and 1. While the first controller "tapactive" is visible when the value is between 0 and 0.9.

    Interior Visibility Object is used to hide cab components, but be aware of that it doesn't hide the "transform" of the object (used by the mouse in cab) This is why I mentioned using animation to hide the object, since this also hides the transform which is needed in some cases.

    BlueprintEditor2_tMp83zO67p.png
     
  20. wenxdx

    wenxdx New Member

    Joined:
    Sep 1, 2025
    Messages:
    25
    Likes Received:
    1
    ok,I will try
     
    • Like Like x 1
  21. wenxdx

    wenxdx New Member

    Joined:
    Sep 1, 2025
    Messages:
    25
    Likes Received:
    1
    thank you very much
     
  22. wenxdx

    wenxdx New Member

    Joined:
    Sep 1, 2025
    Messages:
    25
    Likes Received:
    1
    btw,if I use the Interior Visibility Object and lock the handle 1 like this
    if 0.9 < Call("*:GetControlValue", "VirtualThrottle", 0) <= 1 then
    Call("*:LockControl", "ControlOff", 0, true)"
    Call("*:SetControlValue", "VirtualThrottle", 0, 0.9)
    else
    .....

    is that is a good idea?
     
  23. Maik Goltz

    Maik Goltz Well-Known Member

    Joined:
    Dec 9, 2016
    Messages:
    1,167
    Likes Received:
    5,229
    Btw. don't use the " *: " if not necessary. That's a wildcard search over all child objects what adds pressure to performance. If you call on the main object (mesh, RV) just use Call("GetControlValue","ControlName",0). When calling on a child use Call("ChildName:GetControlValue","ControlName",0).
     
    • Like Like x 1
  24. wenxdx

    wenxdx New Member

    Joined:
    Sep 1, 2025
    Messages:
    25
    Likes Received:
    1
    Thank you for let me know
     

Share This Page