Lever control system

I’m trying to make a lever that can be dragged into different positions, and depending on which position it’s in, will increase or decrease the throttle of a large vehicle. How would I go about doing this?

Step 1. Select your favorite search engine. I chose Google.

Step 2. Type the subject of this post in along with “unity” appended.

Step 3. ???

Step 4. PROFIT!

6069318--657792--Screen Shot 2020-07-08 at 1.55.02 PM.jpg

I did that. all those tutorials are for On/Off levers. I need one that you can position to any point and it will give off a different thrust value. Believe me, I search all over the net before asking questions here but thank you for the sarcasm.

You’re welcome! It just seemed unlikely that it couldn’t be found on the net, and I’m actually sure it’s out there somewhere still, as there are quite a few racing games that are throttled.

In any case, I offer you this little “hovering” demo game with a touchscreen analog throttle, works fine on mobile touch targets too:

http://www.plbm.com/hovering/index.html

The key takeaway for you is the 2D analog control, in this case a 2-axis one that combines throttle with steer, but there’s no reason you can’t just put two of them onscreen and have one only pay attention to throttle up/down, and have the other pay attention to steer left right.

The actual finger-sensing (or mouse sensing) script is called VAButton. The scenes set the single VAButton up to take the entire width of the lower screen. To split throttle from steering, make two VAButtons, one on the left, one on the right. You would give them separate rectangles.

I actually use that VAButton code in all my games on mobile. There’s an equivalent in the Unity Standard Assets but I always found it multiple times harder to set up quickly, so I made my own.

Full source and project located here, your choice of git host:

Hovering is presently hosted at these locations:

https://bitbucket.org/kurtdekker/hovering

https://github.com/kurtdekker/hovering