Suggestion for improving event controller's interaction with rotors (and maybe hinges)
I've noticed that event controllers that are checking a rotor's angle seem to do so with a lot of precision, yet only seem to check once a frame. This means the rotor usually skips over the angle you want the event controller to trigger on, so the event controller doesn't trigger. I was thinking that maybe when an event controller is watching a rotor, some predictive math could take place in each frame to ensure it actually detects the right angle without sacrificing the ability to have high precision.
I'm not super experienced with programming and I don't know how space engineers 2's code is written, but my idea is something like this:
Each frame runs this calculation for a rotor being watched by an event controller:
i = initial rotor angle
f = next frame rotor angle
d = angle event controller checks for
v = angular velocity in deg/sec
s = simulation speed in frames/sec
g = gap between initial angle and 0/360 (used to adjust angles so i is always 0 to avoid problems from crossing 0 in calculations)
Fake code to communicate idea with python syntax:
#calculating angle of rotor in next frame, if rotor is accelerating that can be accounted for but is a little more complicated
f = i + v*(1/s)
#calculating gap from i to 0° so other angles can be based off i being 0°
g = 360 - i
#adjusting next frame angle and event angle as if i were 0°
f = f + g
d = d + g
#adjusting f and d again to stay within 0-360
if f >= 360:
f = f - 360
elif f < 0:
f = f + 360
if d >= 360:
d = d - 360
elif d < 0:
d = d + 360
#checking if event angle will be passed by next frame and, if so, triggering the event on next frame
if v.is_positive() == True:
if f >= d:
trigger_event()
if v.is_positive() == False:
if f <= d:
trigger_event()
End fake code
This only works if rotors angles are recorded from 0-360 degrees and if 360 is always instantly changed to 0°. I think this would also be a good change to make anyways as it's more useful this way. If the event happens to be to change angular velocity to 0, it would also be nice if the rotor's angle was set to the desired angle that the event controller was checking for.
Thanks for reading, the code above might have a bug or two if you ran it in python (assuming I got syntax fully correct), but the math should check out as long as the initial angle is always between 0 and 360. I really hope you guys can implement something like this because the usefulness of rotors is quite limited right now due to the inability to reliably detect angle. A similar kind of predictive math might be usable in other areas as well.
I like this feedback
Replies have been locked on this page!