Cab controls not initialising properly

General discussion about Train Simulator, your thoughts, questions, news and views!

Moderator: Moderators

MaikG
Well Established Forum Member
Posts: 545
Joined: Sat Oct 08, 2011 5:04 pm

Re: Cab controls not initialising properly

Post by MaikG »

I assume that you hopefully not test this in free roam?!? In free roam the RV is a nonPlayer at start and becomes Player as soo as you possess it. But then it resets all its controls to start values again that are hard coded in TS core, like the Startup. And all animation are stuck at their last positions from nonPlayer state until you move them with the mouse or key controls. Therefor i'm testing since years only in quickdrive mode because you always have a fresh scenario with isPlayer state true at the start.

And you don't need to have the same frame counts for all your animations. At least the minimum animation time need to be 1 second and not below this for cab controls or the interpolation will go wrong. It doesn't really matter if you have a 15 frame anim at 15fps or a 150 frame animation at 150fps. The result will be the same on a control because of normalisations (0-1). Of course not for external animations or non linear animations. I know the myth that all cab anims need to be on the same fps but that is just a wrong advice from the old dev docs. You can have animations with multiple fps settings on one RVs cab. They only need to have the minimum of 1 second in time. In 3dsMax there is no way to have different fps within a model, so all will have the same fps at least. But you don't need to put the keys along all the timeline for short or linear animations. They always geht interpolated by TS (sometimes it goes wrong win 90°+ animations with too less keys). The main problem here (i would say it is a problem) is, when you apply 120 frames at 30fps for your wipers animation and then the same for a lever in the cab, the lever has a anim time of 4seconds what causes TS to slow it dows extremely with controls that interpolates them. Don't know why this happens, but it does. You then need to set the sensitivity to very high values to get the control moving faster. And if you then set the control value via script the lever could move very slowly to its desired value (that's where the SetControlTargetValue becomes important).

I could write thousands of lines more for all these things, but in won't :)
User avatar
chrisell
Well Established Forum Member
Posts: 533
Joined: Mon May 06, 2002 12:00 am
Location: England, Holland and America
Contact:

Re: Cab controls not initialising properly

Post by chrisell »

I test all my trains in free roam and quickdrive. Oddly I've found the opposite of you. In free roam, all my initialisation and cab animations work 100% of the time. I've never had it fail to put things in the right place. For me it's only once I get into quickdrive or standard scenarios that everything breaks. Literally as the camera jumps into the cab, I hear all the one-shot target sounds play at once and then a bunch of my controls are sitting half-animated until I touch them with the mouse.

The cab animations and sensitivity is something I've come across time and time again, so yes, I've seen the poor sesitivity with many frames. The +-90 degree thing is normally OK if you use TCB rotation controllers in max as long as you have at least three keyframes.

SetControlTargetValue --- honestly this is the first time I've seen this mentioned. Should I ask what that does? I've used GetControlValue and SetControlValue of course, but not SetControlTargetValue. I'm not 100% sure if I've seen that in the dev docs either. I just checked the engine scripting docs and I didn't see it in there....
MaikG
Well Established Forum Member
Posts: 545
Joined: Sat Oct 08, 2011 5:04 pm

Re: Cab controls not initialising properly

Post by MaikG »

A control with lager min and max numbers and long animations do lerp into the value you set with SetControlValue. To prevent this lerping and set the control directly to the desired value, you need to use SetControlTargetValue and it snaps right to the place you want (normally, not on all controls). These long animations may cause your problems. The levers and knobs move to slow when the RV initializes. You may know that TS sets all controls to their default value on start, even if you won't that. If you have a slow control it will stuck at a certein position between min and max when the controls value you set via secipt is not the default value. That's a really complex thing and i did not figured it out at all. It's like a lottery.
User avatar
chrisell
Well Established Forum Member
Posts: 533
Joined: Mon May 06, 2002 12:00 am
Location: England, Holland and America
Contact:

Re: Cab controls not initialising properly

Post by chrisell »

Wow. I had no idea you could stop the control value interpolation. Holy . that would have been useful about three years ago! I'm going to have to experiment with SetControlTargetValue. Out of interest how did you find out about that call? I can't find it documented anywhere.
MaikG
Well Established Forum Member
Posts: 545
Joined: Sat Oct 08, 2011 5:04 pm

Re: Cab controls not initialising properly

Post by MaikG »

I got different docs from DTG. This feature is not explained in the public documents. Maybe because it does not work as expected all the times.
User avatar
chrisell
Well Established Forum Member
Posts: 533
Joined: Mon May 06, 2002 12:00 am
Location: England, Holland and America
Contact:

Re: Cab controls not initialising properly

Post by chrisell »

Are those docs anything you can share ? Now I'm curious what else there is that we can use that they didn't tell us about :(
MaikG
Well Established Forum Member
Posts: 545
Joined: Sat Oct 08, 2011 5:04 pm

Re: Cab controls not initialising properly

Post by MaikG »

No, can't share. There is no more you can use. The TargetValue call is the only difference in the engine scripting doc.
User avatar
chrisell
Well Established Forum Member
Posts: 533
Joined: Mon May 06, 2002 12:00 am
Location: England, Holland and America
Contact:

Re: Cab controls not initialising properly

Post by chrisell »

Is the call basically the same format as SetControlValue?
User avatar
TrabantDeLuxe
Been on the forums for a while
Posts: 190
Joined: Fri Feb 20, 2015 6:10 pm

Re: Cab controls not initialising properly

Post by TrabantDeLuxe »

SetControlTargetValue works the same as SetControlValue for me. Its one of those undocumented calls, but i think it follows Maik's earlier description
User avatar
chrisell
Well Established Forum Member
Posts: 533
Joined: Mon May 06, 2002 12:00 am
Location: England, Holland and America
Contact:

Re: Cab controls not initialising properly

Post by chrisell »

Thanks
jstange
Very Active Forum Member
Posts: 1847
Joined: Wed Apr 04, 2012 5:46 pm

Re: Cab controls not initialising properly

Post by jstange »

Hello Chris, did the above do the trick and resolved the issue with RS1? Is the RS1 release in danger?
User avatar
chrisell
Well Established Forum Member
Posts: 533
Joined: Mon May 06, 2002 12:00 am
Location: England, Holland and America
Contact:

Re: Cab controls not initialising properly

Post by chrisell »

jstange wrote:Hello Chris, did the above do the trick and resolved the issue with RS1? Is the RS1 release in danger?
I don't know yet. I was away all last week on vacation so I'll be looking into this this week to see if I can improve the behaviour of the cab.
jstange
Very Active Forum Member
Posts: 1847
Joined: Wed Apr 04, 2012 5:46 pm

Re: Cab controls not initialising properly

Post by jstange »

Understood. Good luck and please keep us posted!
User avatar
chrisell
Well Established Forum Member
Posts: 533
Joined: Mon May 06, 2002 12:00 am
Location: England, Holland and America
Contact:

Re: Cab controls not initialising properly

Post by chrisell »

@maikg - still not clear on one thing - how can you tell in the script if the game is starting new, or from a resume? I can't initialise the controls to the values I want every time in case the player is resuming a game. In that case I need to somehow re-init to the value stored last time it was saved.
User avatar
chrisell
Well Established Forum Member
Posts: 533
Joined: Mon May 06, 2002 12:00 am
Location: England, Holland and America
Contact:

Re: Cab controls not initialising properly

Post by chrisell »

I thought I should follow up with what I found.
Turns out this was a complete coding F*ck up. I have a reasonably complex interlock between a console key and a console 'on/off' button. The key is locked in place when the console is 'on' and the console on/off buttons are locked when the key is out. There's a ton of other controls that get locked at various stages. During initialisation, it ripped through the on/off and key code so quick that it locked, unlocked, then re-locked the console, interrupting all the animations.
I've thrown an initialisation delay in the logic for the lock/unlock/key functions so they don't spam the initialisation process when the game is starting up. Now everything works.
I also had to reduce the animations from 120 frames to 15 to make them complete reliably.
There was some other code cleanup too but the takeaway from this was just the stupid complexity of the console lock functions.
Locked

Return to “[TS] General Discussion”