For this tutorial im going to be using my T3b tank
Well a turret is very simple. Basically what we have to do is tell the game which pieces go together.
As you can see the bottom of the turret moves but the barrels stay in place.
We fix this by linking things together
First Select all the barrels
Then link both of them to the base.
What this will do is make the base the parent of the barrels. Wherever the parent goes the children go with it.
Vertical movement is a small bit more tricky than normal 2d turrets. Lets get started
Set up your turret the same way you did above. Make sure it moves left and right correctly
Move it left and right.. Works fine.. Now try to move the barrelts up and down.. while the base is sideways.. Uh oh.. wont work right.. lets find out why
Reset the turet back to default
Before we fix this though.. we have to set the pivot point for the turret.
go to the hierarchy tab as shown in the pic.
In that side panel click on affect pivot only.
Okay now notice that the move cursor in the viewports will change to different types of arrows
the big arrows show where the pivot point is.. and in what direction it is pointing at.
This is also where it will rotate from, the center of rotation.
so first we need to move it so that when it moves.. the turret barrels rotate in the way we want to.
Moving the pivot point too close to the center of the model gives me a bad rotation arc. Not what i want.
In my case moving it closer to the center of the base gives me a better more realistic roation arc. Experiment with it until you get a good pivot point location.
Once you find the "sweet" spot, move on to the next step.
You will notice that if you rotate it both left and up it will still mess up
What we need to do is mess with the link a little bit.
the most important thing to do is lock the rotation on Y axis. This will allow the turret to lock the pivot point Y axis with the turret no matter which way its facing. However your turret may have different needs change it to suit your set up.