Stormworks: Build and Rescue

Stormworks: Build and Rescue

Not enough ratings
Logic - Tilt sensor conversion
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
25.556 KB
20 Aug, 2018 @ 8:13am
20 Aug, 2018 @ 8:29am
2 Change Notes ( view )

Subscribe to download
Logic - Tilt sensor conversion

In 1 collection by Tajin
Logic Examples & Knowhow
54 items
Description
Tilt sensors have some limitations as they return only values from -0.25 to 0.25 turns. Meaning that when you do a full rotation, you get the same values twice.
This can be overcome by using two tilt sensors at a 90° angle and a bit of math.

So this example shows the setup and includes two functions for converting the tilt output into something more useful.


Display and function on the left convert the rotation into the -0.5 to 0.5 format (similar to how the compass works).
The function on the right converts it to a 0-1 value. In both cases 0 is pointing up (as indicated by the red triangle).
3 Comments
Tajin  [author] 4 Apr, 2022 @ 8:07am 
@Grimper I've sent you a function block code on discord that you can use for that.
Grimper 4 Apr, 2022 @ 2:04am 
Any chance you could extend this so that it can be moved to specific angles like a robotic pivot? I tried doing it myself by just plugging the output of this into a velocity-to-robotic converter, and it kinda works....but has issues with violently flipping around when it passes 1 and goes back to 0.

I assume this is caused by converters expecting the CurrentRotation value of a velocity pivot to keep going up indefinitely rather than reverting back to 0 like yours does, but I don't have the mathematical expertise to fix it.
♛Succubus♛ 25 Oct, 2020 @ 3:58pm 
can i take your tilt to build my stabilization system for missiles?