E2 Turret with 2 axis with applytorque and quaternaries

Hey guys, 1st of all I only started playing Gmod last week, and I’m loving it. As of that I’m still fresh in almost all aspects of the game, but I’m always trying to learn. Almost from the beginning I started checking out and code on E2, simple stuff and all.
My project now it’s making a turret, a gyro one, that only spins the Y and Z axis that I will put in a future b-17 bomber.

I can make turrets with applyangforce(), they work good, are fast turning and I can make the turret face the way I want. And the turret would work if you put it upside down or on his side. Only problem is that if you’re facing the turret he just flips and start shaking all over trying to point at him. Another thing is if I place the seat welded to the Z turret (as the they work in RL) It will shakes all over and I can’t aim.

So as I’ve seen in some threads here I tried to make one using quaternaries and applytorque.
Here’s the code I have for the Z axis for example (I have 2 chips for each axis, I know I can change that but didn’t spent the time on it).

Remind that this is only the Z axis code

And here’s a pic of a basic structure of what I want to do.


Ok the deal is, I tought the turret would face the way the arrow in the chip is pointing (like in applyangforce) but no it aims in another position, for example in a rectangular shape the turret would point from the larger side of the rectangle, instead of the smaller one. If I’m being too confusing, Imagine I made a gun prop, and instead it was aiming down the barrel, it would aim from the magazine for example.

Any help in making this code better is appreciated and help me understand some more of the applytorque keeping in mind it’s the B-17 turret I want to make.

Thanks in advance guys!


You should ask on wiremod.com forums for E2 help.