Ok so I was working on my newest creation that needs to be trimmed in the roll axis, and I thought one way of doing it would be to find the correct trim when there was no roll input from the player, store that trim value, and make it a new constant. This would mean that the trim would not fight the players inputs, and it would be a constant value that would not bother the player or induce any strange movements in the aircraft. I knew how I would implement everything except how I would store the trim value, as to my knowledge there was no way to store information. That’s when I realized that the Time based functions can be used to store information across Time. The easiest to use that I found was the smooth(x,rate) function. The way to store information, x, is to make the rate of x go to zero. Then it is as simple of finding the input that will cause the immediate value of x to be stored. What I used was smooth(RollAngle,clamp01(Roll=0)*100). This would allow RollAngle to change freely until a roll input was made by the player that made roll not equal to zero. I know this is complicated so here is another example I made that uses this for addition.
.
This is the code for the left rotator
The code for the middle rotator
The code for the right rotator
all of the rotators start at zero
when vtol is moved, nothing happens because neither activation groups are activated and therefore the smooth function on both rotators limit the rate of vtol to zero
when ag1 is activated, the first rotator is allowed to move to the value of VTOL
when ag1 is deactivated, the value of VTOL is stored whatever it was at the time of deactivation
and vtol can be moved without affecting the stored value in the first rotator
By activating ag2, the second rotator is allowed to match VTOL
and when ag2 is deactivated, the second rotator stores the value of VTOL
it is not the rotators that store the values but the code itself. The rotators are all set to ag0 and are always active
.
.
.
Dude, you absolute legend. This changes the game. I’ll be using this stuff in a camera controlled glide bomb. Thank you!
@scratch wow imagine how much more laggy it would get XD
welp, time to code the whole of SP into a game engine coded from an operating system in a computer made in SP
This also is the driving principle behind the workings of the stopwatch. What's more, you can even store longer numbers to specifically code for certain events and create processors.
Definitely why the smooth function remains one of the most important functions we have. As for the rate though, I personally recommend using a really large number, like pow(10,5) in order to ensure that the function properly "snaps" to any value.
Nice tutorial! (Or at least I assume it is, you should probably add a tutorial tag to this post). The Idea is pretty well explained in this and I really like those examples with rotators
link to craft@An2k
Can you link that craft from the picture as unlisted in here?..would like to study codes with my puny mind.
Wdym @UnderScore
Woah. You know how to do this using SR2’s Vizzy?