How to make a functional plane's gas lever?

Hi guys, I’m developing a fully functional aircraft for Unreal engine 4, so that those who want to make their own flight simulator in this beautiful game engine have the basis to do it. However, I’m stuck on one part. I already know how to do to move the gas lever with the mouse, now, how can I do to get the percentage of gas I’m giving to the engines based on the position of the lever?
Any ideas guys? I’ll be sure to include the name of the user who helps me solve the problem in this super ambitious project for Unreal engine.

Can you show how you setup the lever?

Already Shoot down the PC right now. I,ll show You guys how i seted up.

Ok so, the blueprint is too big to enter on a only picture, but, in order to do the lever to work i followed this video, and it worked 100%

Update: I already made a way to convert the lever location to the % of fuel i’m injecting to the engine, the problem is, i only can do it on a static point, if i move the object in the world, the % move with it. And i always want to be from 0 to 100%
here’s the pic of how i did the %

Any clue how can i make the % only get affected with the place the lever is between the Cut position and Rich Mixture position?

Update 2: Already fixed the amount between 0 and 100 using a Clamp, what i want to do, no matter wherever the plane is in the world, if i don’t move the gas lever … i always want to be in the same percentage. Any ideas?

Think that approach might be too much for a simple lever. You could have its rotation look at the mouse when clicked, clamping the levers rotation. Much like how it could be done in VR. For example: https://www.youtube.com/watch?v=o5S4ICq1E7M

And the BP for this is quite simple:

(looking back I see this could be better… it’s just an example :sweat_smile:)

Having the mouse interacting with an invisible collision the shape of the lever should work the same way. You can even have an invisible box following the mouse and the lever moving at X speed after that box giving the illusion that the throttle is heavy.

I’ll share later an example with a lever using the mouse.

cool!! I’ll be waiting, later i will record a small video of Microsoft Flight simulator just to give an example of what i want to achieve.
BTW: Man, you just read my mind!! hahahaha, if i get it to work on PC, later i want to move this work into VR!!!
Yeap!! That’s ambicious!! I’m in NoFAP challange, and NoFAP made me become 200% more ambicious XD.

Ok… Lets see if this makes sense:

  1. The setup:
  • LevelPivot is a scene component I’m using to hold the handle. More on it later.
  • Everything else is just a static mesh component but the text.
  • The CollisionCyndiler is a normal cylinder that has visible set to false leaving only the collision. This will help us get a location from the mouse trace that is spherical to the center (LevelPivot). this is what the cylinder looks like with visible set to true:
  1. Enable Click Events:
    image

  2. To activate, player has to click the handle:

  • The actor has tick disabled by default. It’s only activated when clicked.
  • We need to enable Input on this actor because it needs to listen when the player releases LMB to stop working.
  • Notice I change the handle collision response to visibility: this is so the mouse trace only hits the cylinder. Helps get a smooth rotation of the handle when following the mouse.
  1. To disable the BP:
  • The purpose of the bool is to block the LMB input if ithe player releases without clicking on the handle first. This is not necesarry since Input is disabled anyways…
  • Disable tick and disable input for this actor so it stays static.
  • We set handle collision back to block so it can be triggered again.
  1. Not much to explain here:
  • First is we transform the mouse hit location to relative. This will make the lever work no matter how it is oriented in world space.
  • We clamp the level to our desired limits.
  • Map Range Clamped allows to map a range to what ever other range you want.

Result:
Levers

4 Likes

Holy MADONA!!! This was by far the most complete answer i ever had here!!! oooooh! that EXACTLY what i was looking for!!! Perfectly nailed. The plane i’m doing is based on the Beechcraft King Air. Now with this, i feel safe to do even further and make commercial planes too!!! NEXT BIG STEP WILL BE THE AUTOPILOT, but, i’ll go dispelling doubts when problems comes in.
YOU ROCK MAN!!!

1 Like

:medal_sports:

CONFIRMED! IT WORKS!!! :smiley: :smiley: :smiley: Man, can’t believe the luck i’m having this year!!! Of course, as i’m using an older version, 4.24 it doesn’t work 100% but, hey, at least in some point, it does the function. :wink:

2 Likes