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?
This is the link of that addon https://store.steampowered.com/app/...strecke_Leipzig__Riesa_Route_Extension_AddOn/
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.
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
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.
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
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".
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
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.
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.
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?
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).